SeriesnotFound @ 2023-05-30 17:28:17
如题。
#include<iostream>
using namespace std;
void paste(int start, int end, int head);
long long n = -1, k = -1;
long long list[100000];
int main(){
cin >> n >> k;
for (int i = 1; i <= n; i++){
list[i] = i;
}
long long start = 0, end = 0, head = 0;
for (int j = 0; j < k; j++){
cin >> start >> end >> head;
paste(start, end, head);
}
for (int l = 1; l <= 10; l++){
cout << list[l] << endl;
}
}
void paste(int start, int end, int head){
int plen, phead;
phead = head + 1;
plen = end - start + 1;
long long current[100000], ct = 0, buffer[100000];
ct = 0;
for (int i = phead; i < start; i++){
buffer[ct] = list[i];
ct++;
}
ct = 0;
for (int i = start; i <= end; i++){
current[ct] = list[i];
ct++;
}
ct = head + 1;
for (int i = 0; i < plen; i++){
list[ct] = current[i];
ct++;
}
ct = phead + plen;
for (int i = 0; i < start - phead; i++){
list[ct] = buffer[i];
ct++;
}
}