分析:算1和2的起点在哪里,然后往后累加就可以了。
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> using namespace std; int ans[1000005]; int main() { //freopen("1.in","r", stdin); //freopen("1.txt","w",stdout); int n, m; while(~scanf("%d %d", &n, &m)) { int x, y; int sum1=1, sum2=2; for(int i=1; i<=m; i++) { scanf("%d", &x); if(x==1) { scanf("%d", &y); sum1+=y; sum2+=y; sum1%=n;sum1+=n;sum1%=n; sum2%=n;sum2+=n;sum2%=n; } else { if(sum2%2) { sum1--; sum2++; } else { sum1++; sum2--; } sum1%=n;sum1+=n;sum1%=n; sum2%=n;sum2+=n;sum2%=n; } } sum1%=n;sum1+=n;sum1%=n; sum2%=n;sum2+=n;sum2%=n; for(int i=1; i<=n; ) { if(sum1==0) sum1 = n; if(sum2==0) sum2 = n; ans[sum1] = i++; ans[sum2] = i++; sum1=(sum1+2+n)%n; sum2=(sum2+2+n)%n; } for(int i=1; i<=n; i++) printf("%d%c", ans[i],i==n?‘\n‘:‘ ‘); } return 0; }
时间: 2024-11-05 18:49:24