当前位置:网站首页>洛谷P1188 PASTE
洛谷P1188 PASTE
2022-08-07 04:53:00 【CLH_W】
题目描述
我们用文本处理器来处理一个特殊的文本文件,该文本文件共有N行文本,每一行文本仅包含一个自然数,第一行为11、第二行为22,以此类推至N行为自然数NN。
假设对该文本文件执行一次“剪切和粘贴”操作含义如下:首先选定连续的若干行文本,“剪切”操作将选定的文本从文件中剪下,而“粘贴”操作将剪切下来的文本插入到文件中的其他地方。
编写一个程序求出在进行了连续若干次“剪切和粘贴”操作后,文本文件中前十行的内容。
输入格式
第一行包含两个用空格隔开的自然数NN和KK,NN表示文件的总行数(10≤N≤100,000)(10≤N≤100,000),K表示“剪切和粘贴”的总次数(1≤k≤1000)(1≤k≤1000)。
下面KK行每一行包含一次“剪切和粘贴”操作的执行信息,每行包含三个用空格隔开自然数A,B,CA,B,C,其中1≤A≤B≤N,0≤C≤N-(B-A+1)1≤A≤B≤N,0≤C≤N−(B−A+1)。AA和BB表示选定文本的第一行和最后一行,CC表示被剪切下来的文本待插入处的前一行,如果CC等于00则被剪切下来的的文本将被插入到文件的开头。
输出格式
由十行组成,其中包含所有的操作都完成后的文本文件中前十行所包含的数字。
输入输出样例
输入 #1复制
13 3
6 12 1
2 9 0
10 13 8
输出 #1复制
6
7
8
9
10
11
12
2
3
4
上代码:
#include<bits/stdc++.h>
using namespace std;
int n,k,A,B,C;
vector <int> text;
vector <int> paster;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++)text.push_back(i);
for(int i=1;i<=k;i++){
cin>>A>>B>>C;
paster.assign(text.begin()+A-1,text.begin()+B);//把A到B这一段复制到粘贴板
text.erase(text.begin()+A-1,text.begin()+B);//删掉A到B这一段
text.insert(text.begin()+C,paster.begin(),paster.end());//把粘贴板里的内容粘贴到C的位置
paster.clear();
}
for(int i=0;i<10;i++)cout<<text[i]<<endl;//输出前10行
return 0;
}
边栏推荐
- openssl 1.1.1k & libsrtp2-dev 2.3.0-2安装
- Brush the title "Sword Finger Offer" day11
- 2022 Niu Ke Duo School Six J-Number Game (Simple Reasoning)
- The second virtual camera: configure the v4l2loopback virtual camera as the front or rear camera
- Fedora 团队宣布 Fedora 36 系统发布了
- Fedora Team Announces Fedora 36 System Release
- 线性代数学习笔记5-2:(正交的)投影、投影矩阵、A^T A、最小二乘法LS
- Parse the structure inside the wpf control
- 刷题《剑指Offer》day11
- 《研究生科研能力训练与培养》
猜你喜欢

Linear Algebra Study Notes 4-6: Null Space, Column Space, Row Space, Left Null Space, Elementary Row Transformation, Test Questions of Matrix

4G dtu remote wireless meter reading

Brush the title "Sword Finger Offer" day11

Industrial 5g router manufacturers

ansible——playbook剧本的讲解与应用

Some basic concepts and methods of proxy ip (updating...)

position sticky与overflow冲突失效无作用,解决办法

Tips for recording WPF (2) 16-30

"go1.15.3" does not match go tool version "go1.13.8"

What is SaaS service platform software?
随机推荐
One Pass 1225 - Treasure Island
openssl 1.1.1k & libsrtp2-dev 2.3.0-2 installed
Small application container in the application of integrated online government service platform
Character Desensitization Tool
openssl 1.1.1k & libsrtp2-dev 2.3.0-2安装
【LeetCode Daily Question】——Square root of 69.x
ansible——playbook剧本的讲解与应用
Collections and Iterators
Sigrity PowerDC仿真
线性代数学习笔记4-6:矩阵的零空间、列空间、行空间、左零空间、初等行变换、测验题
Project management knowledge points
tiup cluster help
position sticky与overflow冲突失效无作用,解决办法
线性代数学习笔记6-4:行列式的应用(用伴随矩阵求逆矩阵、克莱姆法则解方程、行列式求面积/体积)
Golang = is summarized
Problems encountered with Flutter environment configuration
MySQL---Single-table and multi-table query exercises
Automated operation and maintenance tools - ansible overview and deployment
线性代数学习笔记6-2:行列式的理解、行列式的性质
navicat linked server mysql