Submission #230093

# Submission time Handle Problem Language Result Execution time Memory
230093 2020-05-08T07:45:42 Z dolphingarlic Nizovi (COI14_nizovi) C++14
90 / 100
163 ms 384 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int cmp(int X, int Y) {
    cout << "cmp " << X << ' ' << Y << endl;
    cin >> X;
    return X;
}

void rev(int X, int Y) {
    cout << "reverse " << X << ' ' << Y << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    for (int A_ptr = 0, B_ptr = 0; A_ptr < A && B_ptr < B; A_ptr++) {
        if (cmp(A_ptr + B_ptr + 1, A + B_ptr + 1) == -1) continue;
        
        int l = A + B_ptr + 2, r = A + B + 1;
        while (l != r) {
            int mid = (l + r) / 2;
            if (cmp(A_ptr + B_ptr + 1, mid) != -1) l = mid + 1;
            else r = mid;
        }

        if (A_ptr + 1 != A) rev(A_ptr + B_ptr + 1, A + B_ptr);
        if (A + B_ptr + 1 != l - 1) rev(A + B_ptr + 1, l - 1);
        rev(A_ptr + B_ptr + 1, l - 1);

        B_ptr = l - A - 1;
    }
    cout << "end" << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
5 Correct 26 ms 384 KB Output is correct
6 Correct 29 ms 384 KB Output is correct
7 Correct 144 ms 384 KB Output is correct
8 Correct 161 ms 384 KB Output is correct
9 Correct 154 ms 384 KB Output is correct
10 Incorrect 163 ms 384 KB Total cost of reverse commands > 3 000 000