fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long int
  3. #define ull unsigned long long int
  4. #define pb push_back
  5. #define mp make_pair
  6. #define vi vector<int>
  7. #define vvi vector<vi>
  8. #define Max(a,b) ((a)>(b)?(a):(b))
  9. #define Min(a,b) ((a)<(b)?(a):(b))
  10. #define rep(i,a,b) for(ll i=a;i<b;i++)
  11. #define all(a) a.begin(),a.end()
  12. #define sum(a) accumulate(all(a),0)
  13. #define endl '\n'
  14. #define hell 1000000007
  15.  
  16. using namespace std;
  17. template <class X>
  18. void input(vector<X>&a,int N){
  19. X temp;
  20. rep(i,0,N){
  21. cin>>temp;
  22. a.push_back(temp);
  23. }
  24. }
  25. void solve(){
  26. ll n,q;
  27. cin>>n>>q;
  28. ll oddmoves=0;
  29. ll evenmoves=0;
  30. rep(i,0,q){
  31. ll ch;
  32. cin>>ch;
  33. if(ch==1){
  34. ll temp;
  35. cin>>temp;
  36. oddmoves+=temp;
  37. evenmoves+=temp;
  38. }
  39. else{
  40. if(oddmoves%2==0){
  41. oddmoves+=1;
  42. evenmoves-=1;
  43. }
  44. else{
  45. oddmoves-=1;
  46. evenmoves+=1;
  47. }
  48. }
  49. }
  50. oddmoves=(oddmoves%n+n)%n;
  51. evenmoves=(evenmoves%n+n)%n;
  52. if(oddmoves%2==0){
  53. int oddstart=(1-oddmoves+2*n)%n;
  54. int evenstart=(2-evenmoves+2*n)%n;
  55. rep(i,0,n/2){
  56. if(evenstart==0)evenstart=n;
  57. cout<<oddstart<<" "<<evenstart<<" ";
  58. oddstart=(oddstart+2)%n;
  59. evenstart=(evenstart+2)%n;
  60. }
  61. }
  62. else{
  63. int evenstart=(1-evenmoves+2*n)%n;
  64. int oddstart=(2-oddmoves+2*n)%n;
  65. rep(i,0,n/2){
  66. if(evenstart==0)evenstart=n;
  67. cout<<evenstart<<" "<<oddstart<<" ";
  68. oddstart=(oddstart+2)%n;
  69. evenstart=(evenstart+2)%n;
  70. }
  71. }
  72. }
  73. int main(){
  74. ios_base::sync_with_stdio(false);
  75. cin.tie(0);
  76. cout.tie(0);
  77. int t=1;
  78. while(t--){
  79. solve();
  80. }
  81. return 0;
  82. }
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty