0分求助!
查看原帖
0分求助!
1024403
AVL_DORT_MCI_BAR_CHN楼主2023/8/29 22:01
#include<bits/stdc++.h>
using namespace std;
int a[1000005],b[1000005],bb[1000005];
int main(){
	int n,t;
	cin>>n>>t;
	for(int i=1;i<=n;i++) a[i]=i;
	for(int i=1;i<=t;i++){
		memset(bb,0,sizeof(bb));
		memset(b,0,sizeof(b));
		int l,r,c,k=0;
		cin>>l>>r>>c;
		for(int j=l;j<=r;j++){
			b[++k]=a[j];
		}
		int kk=k;
		k=0;
		if(r<c){
			for(int j=r+1;j<=c;j++){
				bb[++k]=a[j];
			}
			k=0;
			for(int j=l;j<=l+c-r-1;j++){
				a[j]=bb[++k];
			}
			k=0;
			for(int j=l+c-r;j<=kk+l+c-r-1;j++){
				a[j]=b[++k];
			}
		}
		else if(r>c){
			for(int j=c+1;j<=l-1;j++){
				bb[++k]=a[j];
			}
			int kkk=k;
			k=0;
			for(int j=c+1;j<=kk+c;j++){
				a[j]=b[++k];
			}
			k=0;
			for(int j=kk+c+1;j<=r;j++){
				a[j]=bb[++k];
			}
		}
	}
	for(int i=1;i<=10;i++) cout<<a[i]<<endl;
	return 0;
}
2023/8/29 22:01
加载中...