Submission #243715

# Submission time Handle Problem Language Result Execution time Memory
243715 2020-07-01T16:00:44 Z kingfran1907 Nizovi (COI14_nizovi) C++14
100 / 100
157 ms 384 KB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5+10;

int a, b;

int cp(int a, int b) {
    printf("cmp %d %d\n", a, b);
    fflush(stdout);

    int x;
    scanf("%d", &x);
    return x;
}

void rev(int a, int b) {
    printf("reverse %d %d\n", a, b);
    fflush(stdout);
}

int main() {
    scanf("%d%d", &a, &b);

    int ptr = 0;
    for (int i = 1; i <= a; i++) {
        int lo = a + ptr;
        int hi = a + b;

        while (lo < hi) {
            int mid = (lo + hi + 1) / 2;
            if (cp(i + ptr, mid) > 0) lo = mid;
            else hi = mid - 1;
        }

        if (lo == a + ptr) continue;
        rev(i + ptr, lo);
        rev(i + ptr, lo - (a - i + 1));
        rev(lo - (a - i), lo);
        ptr += (lo - (a - i + 1)) - (i + ptr) + 1;
    }
    printf("end\n");
    fflush(stdout);
    return 0;
}

Compilation message

nizovi.cpp: In function 'int cp(int, int)':
nizovi.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
nizovi.cpp: In function 'int main()':
nizovi.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 36 ms 384 KB Output is correct
5 Correct 34 ms 384 KB Output is correct
6 Correct 38 ms 384 KB Output is correct
7 Correct 140 ms 256 KB Output is correct
8 Correct 150 ms 384 KB Output is correct
9 Correct 148 ms 256 KB Output is correct
10 Correct 157 ms 256 KB Output is correct