yiyezhiqiu1011 @ 2024-08-14 14:13:55
#include <bits/stdc++.h>
using namespace std;
int m[100005],temp[100005]={};
int main()
{
int n,k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
m[i] = i;
while (k--)
{
int a,b,c,l = 0;
cin >> a >> b >> c;
for (int i = a; i <= b; i++)
{
temp[i - a + 1] = m[i];
m[i] = m[c + i - a + 1];
}
for (int i = a; i <= b; i++)
m[c + i - a + 1] = temp[i - a + 1];
}
for (int i = 1; i <= 10; i++)
cout << m[i] << endl;
return 0;
}
by DGFLSzfd @ 2024-08-14 14:20:27
说句实在话代码还是要自己调试,特别是这种模拟题。调试都不会怎么上考场,怎么把oi这条路走下去……。调试代码的能力也是水平的一种体现。 @yiyezhiqiu1011
by ARzy @ 2024-08-14 14:34:22
@DGFLSzfd 如答
by corner_xiejunqi @ 2024-08-30 11:51:33
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,k;
int a[N],b[N],c[N];
int A,B,C;
void solve(int start,int end,int increat){
memset(b,0,sizeof b);
memset(c,0,sizeof c);
for(int i=start,j=1;i<=end;i++,j++){
b[j]=a[i];
a[i]=0;
}
for(int i=end+1,j=1;i<=n;i++,j++){
c[j]=a[i];
}
for(int i=1,j=start;i<=n-end;i++,j++){
a[j]=c[i];
}
memset(c,0,sizeof c);
for(int i=increat+1,j=1;i<=n-(end-start+1);i++,j++){
c[j]=a[i];
a[i]=0;
}
for(int i=increat+1,j=1;j<=(end-start+1);i++,j++){
a[i]=b[j];
}
for(int i=increat+(end-start+1)+1,j=1;i<=n;i++,j++){
a[i]=c[j];
}
}
int main(){
//1、声明变量,输入
cin>>n>>k;
//2、计算过程
for(int i=1;i<=n;i++){
a[i]=i;
}
for(int i=1;i<=k;i++){
cin>>A>>B>>C;
solve(A,B,C);
}
//3、输出
for(int i=1;i<=10;i++){
cout<<a[i]<<endl;
}
return 0;
}
by corner_xiejunqi @ 2024-08-30 11:54:38
@yiyezhiqiu1011 这个离正确还有点远,你插入了,还要将其他的往后移