fork download
  1. var a,b,d:array[0..10000000] of longint;
  2. q,p,t,p1,n,i:longint;
  3. begin
  4. read(n,q);
  5. for i:=1 to q do
  6. begin
  7. read(t);
  8. b[i]:=t;
  9. if t=1 then
  10. begin
  11. read(t);
  12. d[i]:=t;
  13. end;
  14. end;
  15. p:=1;
  16. p1:=2;
  17.  
  18. for i:=1 to q do
  19. if b[i]=2 then
  20. begin
  21. if p mod 2=1 then inc(p) else dec(p);
  22. end
  23. else
  24. begin
  25. p:=p+d[i];
  26. if p>n then p:=p mod n else
  27. if p<=0 then p:=p+n;
  28. end;
  29.  
  30.  
  31. for i:=1 to q do
  32. begin
  33. if b[i]=2 then
  34. begin
  35. if p1 mod 2=1 then inc(p1) else dec(p1);
  36. end
  37. else
  38. begin
  39. p1:=p1+d[i];
  40. if p1>n then p1:=p1 mod n else
  41. if p1<=0 then p1:=p1+n;
  42.  
  43. end;
  44. //writeln(p1);
  45. end;
  46.  
  47. //writeln(p,' ',p1);
  48.  
  49. for i:=0 to n div 2-1 do
  50. if p+2*i>n then a[(p+2*i) mod n]:=2*i+1 else a[p+2*i]:=2*i+1;
  51.  
  52.  
  53. for i:=0 to n div 2-1 do
  54. if p1+2*i>n then a[(p1+2*i)mod n]:=2*i+2 else a[p1+2*i]:=2*i+2;
  55.  
  56. for i:=1 to n do
  57. write(a[i],' ');
  58. end.
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
Success #stdin #stdout 0s 117440KB
stdin
Standard input is empty
stdout
Standard output is empty