Submission #736286

# Submission time Handle Problem Language Result Execution time Memory
736286 2023-05-05T11:56:52 Z beaconmc Nizovi (COI14_nizovi) C++14
0 / 100
203 ms 292 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
//#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
  ll a,b;
  cin >> a >> b;

  ll stuff[a];
  FOR(i,0,a){
    ll lo = a+1;
    ll hi = a+b+1;
    cout << "cmp " << i+1 << " " << a+1 << endl;
    ll resp; cin >> resp;
    if (resp == -1){
      stuff[i] = -1;
      continue;
    }
    while (lo < hi){
      ll mid = (hi + lo) / 2;
      cout << "cmp " << i+1 << " " << mid << endl;
      ll resp;
      cin >> resp;
      if (resp<=0){
        hi = mid;
      }else{
        lo = mid+1;
      }
    }
    stuff[i] = lo-1;
  }
  ll cur = a;
  ll idk = 0;
  FOR(i,0,a){
    if (stuff[i] == -1){
      idk += 1;
      cur -= 1;
      continue;
    }
    if (i==0 || stuff[i-1] == -1){
      if (i+1 < stuff[i]) cout << "reverse " << i+1 << " " << stuff[i] << endl;;
      if (stuff[i] - cur + 1  < stuff[i]) cout << "reverse " << stuff[i] - cur + 1 << " "<< stuff[i] << endl;
      if (i+1 < stuff[i]-a+idk) cout << "reverse " << i+1 << " " << stuff[i]-a+idk << endl;
      cur -= 1;
      idk = 0;
    }else{

      if (stuff[i-1] == stuff[i]){
        cur -= 1;
        idk += 1;
        continue;
      }
      ll pos = stuff[i-1];
      if (pos < stuff[i]) cout << "reverse " << pos << " " << stuff[i] << endl;
      if (stuff[i] - cur + 1  < stuff[i]) cout << "reverse " << stuff[i] - cur + 1 << " "<< stuff[i] << endl;
      if (pos < stuff[i]-a+idk) cout << "reverse " << pos << " " << stuff[i]-a+idk << endl;
      cur-=1;
      idk = 0;
    }
  }
  cout << "end" << endl;




}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Incorrect
2 Incorrect 2 ms 208 KB Incorrect
3 Incorrect 4 ms 208 KB Incorrect
4 Incorrect 45 ms 280 KB Incorrect
5 Incorrect 53 ms 208 KB Incorrect
6 Incorrect 32 ms 276 KB Incorrect
7 Incorrect 203 ms 284 KB Incorrect
8 Incorrect 160 ms 280 KB Incorrect
9 Incorrect 176 ms 284 KB Incorrect
10 Incorrect 192 ms 292 KB Incorrect