Submission #90605

# Submission time Handle Problem Language Result Execution time Memory
90605 2018-12-22T20:58:47 Z Milki Nizovi (COI14_nizovi) C++14
20 / 100
160 ms 532 KB
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 1e3 + 5;

int a, b;
int sol[MAXN];

int cmp(int x, int y){
  cout << "cmp" _ x _ y << endl;
  fflush(stdout);
  int ret; cin >> ret;
  return ret;
}

void rev(int x, int y){
  if(x == y) return;
  cout << "reverse" _ x _ y << endl;
  fflush(stdout);
}

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

  REP(i, a){
    int lo = a + i + 1, hi = a + b;
    if(lo >= hi) continue;
    while(lo < hi){
      int mid = (lo + hi + 1) >> 1;
      int ans = cmp(i + 1, mid);

      if(ans <= 0)
        hi = mid - 1;
      else
        lo = mid;
    }
    sol[i] = lo;
  }
  int start = 1, len = a + 1;
  REP(i, a){
    len --;
    if(i && sol[i] == sol[i - 1] ) continue;
    if(start > sol[i]) continue;

    rev(start, sol[i]);
    rev(sol[i] - len + 1, sol[i]);
    rev(start, sol[i] - len);
    start = sol[i] - len + 2;
  }

  cout << "end";
  fflush(stdout);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 3 ms 456 KB Incorrect
3 Incorrect 3 ms 456 KB Incorrect
4 Incorrect 38 ms 528 KB Incorrect
5 Incorrect 34 ms 528 KB Incorrect
6 Incorrect 14 ms 528 KB Incorrect
7 Incorrect 157 ms 528 KB Incorrect
8 Incorrect 160 ms 528 KB Incorrect
9 Correct 64 ms 528 KB Output is correct
10 Incorrect 135 ms 532 KB Total cost of reverse commands > 3 000 000