Submission #22188

# Submission time Handle Problem Language Result Execution time Memory
22188 2017-04-29T15:53:19 Z model_code Nizovi (COI14_nizovi) C++14
0 / 100
43 ms 2020 KB
#include <algorithm>
 
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
 
#include <string>
#include <vector>
#include <iostream>
 
using namespace std;
 
typedef long long llint;
 
int main(void)
{
  int n_a, n_b; scanf("%d %d", &n_a, &n_b);
  vector<int> lb(n_a);
 
  llint op_suma = 0;
  int cmd_cnt = 0;
 
  auto out_rev = [&cmd_cnt, &op_suma](int lo, int hi) { // [lo, hi>
    if (lo >= hi) return;
    printf("reverse %d %d\n", lo+1, hi); fflush(stdout);
    op_suma += hi - lo;
    ++cmd_cnt;
  };
  auto is_less = [&cmd_cnt](int x, int y) {
    printf("cmp %d %d\n", x+1, y+1); fflush(stdout);
    int ret; scanf("%d", &ret);
    ++cmd_cnt;
    return ret > 0;
  };
 
  for (int i = 0; i < n_a; ++i) {
    int lo = n_a, hi = n_a+n_b;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      if (is_less(mid, i))
        lo = mid + 1;
      else
        hi = mid;
    }
    lb[i] = lo;
  }
 
  int start = 0;
  int left = n_a;
  int last_idx = n_a;
  for (int i = 0; i < n_a; ++i) {
    int dulj = lb[i] - last_idx;
    out_rev(start+1, lb[i]);
    out_rev(start, start+1+dulj);
    start += 1+dulj;
    --left;
    out_rev(start, start+left);
    last_idx = lb[i];
  }
 
  assert(op_suma <= int(3e6));
  assert(cmd_cnt <= 100000);
  printf("end\n"); fflush(stdout);
 
  return 0;
}

Compilation message

nizovi.cpp: In function 'int main()':
nizovi.cpp:18:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int n_a, n_b; scanf("%d %d", &n_a, &n_b);
                                           ^
nizovi.cpp: In lambda function:
nizovi.cpp:32:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int ret; scanf("%d", &ret);
                               ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2020 KB Incorrect
2 Incorrect 3 ms 2020 KB Incorrect
3 Incorrect 3 ms 2020 KB Incorrect
4 Incorrect 16 ms 2020 KB Incorrect
5 Incorrect 0 ms 2020 KB Incorrect
6 Incorrect 13 ms 2020 KB Incorrect
7 Incorrect 43 ms 2020 KB Incorrect
8 Incorrect 33 ms 2020 KB Incorrect
9 Incorrect 43 ms 2020 KB Incorrect
10 Incorrect 36 ms 2020 KB Incorrect