# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
742168 | 2023-05-15T17:36:05 Z | vanic | Nizovi (COI14_nizovi) | C++14 | 191 ms | 304 KB |
//NIJE TVOJ KOD - SLUZBENO RJESENJE #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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 3 ms | 208 KB | Output is correct |
3 | Correct | 2 ms | 208 KB | Output is correct |
4 | Correct | 45 ms | 292 KB | Output is correct |
5 | Correct | 37 ms | 276 KB | Output is correct |
6 | Correct | 30 ms | 292 KB | Output is correct |
7 | Correct | 191 ms | 296 KB | Output is correct |
8 | Correct | 98 ms | 304 KB | Output is correct |
9 | Correct | 175 ms | 284 KB | Output is correct |
10 | Correct | 115 ms | 284 KB | Output is correct |