fork download
  1. #include<bits/stdc++.h>
  2. #define pir pair<int,int>
  3. #define fi first
  4. #define se second
  5. #define ll long long
  6. #define ldb long double
  7. #define uid uniform_int_distribution
  8. using namespace std;
  9. const int maxn = 5e5 + 5;
  10.  
  11. template <class t1,class t2> inline void maxi(t1 &x,t2 y){if (x < y) x = y;}
  12. template <class t1,class t2> inline void mini(t1 &x,t2 y){if (x > y) x = y;}
  13.  
  14. struct query{
  15. int type,v1,v2;
  16. };
  17.  
  18. query Q[maxn];
  19.  
  20. void input(int q){
  21. for (int i = 1 ; i <= q ; i++) cin >> Q[i].type >> Q[i].v1 >> Q[i].v2;
  22. }
  23.  
  24.  
  25. vector <int> a;
  26.  
  27. void th1(int x,int k,int cur){
  28. int vt = 0;
  29. vector <int> arr;
  30.  
  31. for (int i = 0 ; i < a.size() ; i++)
  32. if (a[i] == x){
  33. vt = i;
  34. break;
  35. }
  36.  
  37. for (int i = vt + 1 ; i < a.size() ; i++) arr.push_back(a[i]);
  38. while (a.size() > vt + 1) a.pop_back();
  39.  
  40. for (int i = cur ; i < cur + k ; i++) a.push_back(i);
  41. for (int v : arr) a.push_back(v);
  42. }
  43.  
  44. void th2(int y,int h){
  45. int l = 0,r = 0;
  46. vector <int> arr;
  47.  
  48. for (int i = 0 ; i < a.size() ; i++)
  49. if (a[i] == y){
  50. l = i + 1,r = i + h;
  51. break;
  52. }
  53.  
  54. for (int i = 0 ; i < a.size() ; i++)
  55. if (i < l || i > r) arr.push_back(a[i]);
  56. a = arr;
  57. }
  58.  
  59. ll th3(int l,int r){
  60. ll res = 0;
  61. l--;r--;
  62. for (int i = l ; i <= r ; i++)
  63. res += a[i];
  64. return res;
  65. }
  66.  
  67. int g(int x){
  68. int n = x +1;
  69. while (n > x) n = rand() % (x + 1) + 1;
  70. return n;
  71. }
  72. int g0(int x){
  73. int n = x + 1;
  74. while (n > x) n = rand() % (x + 1);
  75. return n;
  76. }
  77.  
  78. int main(){
  79. ios_base::sync_with_stdio(false);
  80. cin.tie(0);cout.tie(0);
  81.  
  82. freopen("TSEQ.INP","w",stdout);
  83. int q;
  84. std:: mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
  85. srand(time(NULL));
  86. q = 500;int lim = 500;
  87. uid <int> gk(1,lim);
  88. cout << q << "\n";
  89.  
  90. int cur = 1;
  91. a.push_back(0);
  92.  
  93. for (int i = 1 ; i <= q ; i++){
  94. int type = g(3);
  95.  
  96.  
  97. cout << type << " ";
  98.  
  99. if (type == 1){
  100. int vt = g(a.size()),k = gk(rd),x = a[vt - 1];
  101.  
  102. cout << x << " " << k << "\n";
  103. th1(x,k,cur);
  104. cur += k;
  105. }
  106.  
  107. if (type == 2){
  108. //h can be zero, because of the weak test generator
  109. int vt = g(a.size()),h = g0(a.size() - vt),y = a[vt - 1];
  110. th2(y,h);
  111. cout << y << " " << h << "\n";
  112. }
  113. if (type == 3) {
  114. int l = g(a.size()),r = g(a.size());
  115. if (l > r) swap(l,r);
  116.  
  117. cout << l << " " << r << "\n";
  118. }
  119. }
  120.  
  121. return 0;
  122. }
  123.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty