Submission #745583

# Submission time Handle Problem Language Result Execution time Memory
745583 2023-05-20T13:29:49 Z lukadupli Nizovi (COI14_nizovi) C++14
40 / 100
49 ms 288 KB
#include <bits/stdc++.h>

#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;

bool cmp(int a, int b){
    cout << "cmp " << a << ' ' << b << endl;
    int x;
    cin >> x;
    return x == -1;
}
void rev(int l, int r){
    if(l == r) return;
    cout << "reverse " << l << ' ' << r << endl;
}

int A, B;

void solve(int l, int r){
    if(l == 1) return;

    if(l < r){
        int lo = 1, hi = l - 1;
        if(r < A + B){
            while(hi > lo){
                int mi = (lo + hi) / 2;

                if(cmp(mi, r + 1)) hi = mi;
                else lo = mi + 1;
            }
        }

        rev(l, r);
        solve(r, lo);
    }
    else{
        int lo = l + 1, hi = A + B;
        if(r > 1){
            while(hi > lo){
                int mi = (lo + hi + 1) / 2;

                if(cmp(mi, r - 1)) lo = mi;
                else hi = mi - 1;
            }
        }

        rev(r, l);
        solve(r, lo);
    }
}

int main()
{
    cin >> A >> B;
    rev(1, A);

    int pos = A;
    if(cmp(A + 1, A)) pos = A + 1;

    if(pos == A + B) rev(1, 2);
    else solve(pos, pos + 1);

    cout << "end" << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 3 ms 208 KB Incorrect
3 Incorrect 3 ms 208 KB Incorrect
4 Correct 48 ms 208 KB Output is correct
5 Correct 37 ms 208 KB Output is correct
6 Correct 49 ms 208 KB Output is correct
7 Runtime error 16 ms 276 KB Execution killed with signal 13
8 Runtime error 17 ms 280 KB Execution killed with signal 13
9 Runtime error 15 ms 276 KB Execution killed with signal 13
10 Runtime error 15 ms 288 KB Execution killed with signal 13