답안 #742189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742189 2023-05-15T18:12:36 Z aaaaa Nizovi (COI14_nizovi) C++14
50 / 100
918 ms 312 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 7;

int a,b;
int mjesto[MAXN];

int bs (int x, int lo, int hi) {
    while (lo < hi) {
        int mid = (lo + hi) / 2;
        cout << "cmp " << x << ' ' << mid + a << "\n";
        cout.flush();
        int c;
        cin >> c;
        if (c >= 0) lo = mid + 1;
        else hi = mid;
    }
    return lo - 1;
}

int main () {
    ios_base::sync_with_stdio (false);
    cin.tie (0);

    cin >> a >> b;

    mjesto[0] = a;
    for (int i = 1; i <= a; i++) mjesto[i] = bs (i, mjesto[i - 1] - a, b) + a;

    int lo = 1, hi;

    for (int i = 1; i <= a; i++) {
        hi = mjesto[i];
        int duk = hi - lo + 1, da = a - i + 1, db = duk - da;
        if (duk <= 1 || da == 0 || db == 0) {
            lo++;
            continue;
        }
        cout << "reverse " << lo << ' ' << hi << "\n";
        cout.flush ();
        if (db > 1) {
            cout << "reverse " << lo << ' ' << lo + db - 1 << "\n";
            cout.flush ();
        }
        if (da > 1) {
            cout << "reverse " << hi - da + 1 << ' ' << hi << "\n";
            cout.flush ();
        }
        lo = hi - da + 2;
    }

    cout << "end";
    cout.flush ();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 918 ms 308 KB Execution killed with signal 13
3 Runtime error 770 ms 304 KB Execution killed with signal 13
4 Runtime error 883 ms 308 KB Execution killed with signal 13
5 Incorrect 33 ms 304 KB Incorrect
6 Correct 35 ms 208 KB Output is correct
7 Correct 91 ms 308 KB Output is correct
8 Correct 172 ms 300 KB Output is correct
9 Correct 173 ms 308 KB Output is correct
10 Incorrect 165 ms 312 KB Total cost of reverse commands > 3 000 000