Submission #745587

# Submission time Handle Problem Language Result Execution time Memory
745587 2023-05-20T14:06:55 Z lukadupli Nizovi (COI14_nizovi) C++14
0 / 100
28 ms 276 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 pos, int fall){
    //cout << "solving: " << pos << ' ' << fall << '\n';
    if(pos >= A + B || fall > A + B || pos >= fall) return;

    if(cmp(pos, fall)){
        int l = pos + 1, r = fall - 1;
        while(r > l){
            int m = (l + r) / 2;

            if(!cmp(m, fall)) r = m;
            else l = m + 1;
        }

        if(l == fall - 1 && cmp(l, fall)) return;

        pos = l;
    }
    //cout << "adjusted to: " << pos << ' ' << fall << '\n';
    if(pos >= A + B || fall > A + B || pos >= fall) return;

    int l = fall, r = A + B;
    while(r > l){
        int m = (l + r + 1) / 2;

        if(cmp(m, pos)) l = m;
        else r = m - 1;
    }

    rev(pos, l);
    rev(pos, pos + l - fall);
    rev(pos + l - fall + 1, fall);

    solve(pos + l - fall + 1, l + 1);
}

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

    cout << "end" << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Incorrect 2 ms 208 KB Incorrect
3 Incorrect 1 ms 208 KB Incorrect
4 Incorrect 28 ms 208 KB Incorrect
5 Incorrect 11 ms 208 KB Incorrect
6 Incorrect 26 ms 208 KB Incorrect
7 Runtime error 1 ms 208 KB Execution killed with signal 13
8 Runtime error 1 ms 276 KB Execution killed with signal 13
9 Runtime error 1 ms 208 KB Execution killed with signal 13
10 Runtime error 1 ms 208 KB Execution killed with signal 13