Submission #320753

# Submission time Handle Problem Language Result Execution time Memory
320753 2020-11-09T18:25:13 Z gustason Carnival (CEOI14_carnival) C++17
0 / 100
21 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    int id[n+1];

    int last = 2;
    id[1] = 1;
    for(int i = 2; i <= n; i++) {
        int L = 1, R = i-1, ans = -1;
        //cout << i << ":\n";
        while(L <= R) {
            int mid = ceil((double) (L + R) / 2);

            // try to go right
            int with, without;
            cout << R - mid + 1 << " ";
            for(int j = mid; j <= R; j++) {
                cout << j << " ";
            }
            fflush(stdout);
            cin >> without;

            cout << R - mid + 2 << " ";
            for(int j = mid; j <= R; j++) {
                cout << j << " ";
            }
            cout << i << " ";
            fflush(stdout);
            cin >> with;

            if (with == without) {
                ans = R;
                R = mid - 1;
                continue;
            }

            // try left
            if (L == R) break;

            cout << mid - L << " ";
            for(int j = L; j < mid; j++) {
                cout << j << " ";
            }
            fflush(stdout);
            cin >> without;

            cout << mid - L + 1 << " ";
            for(int j = L; j < mid; j++) {
                cout << j << " ";
            }
            cout << i << " ";
            fflush(stdout);
            cin >> with;
            if (with == without) {
                ans = L;
                L = mid + 1;
            } else break;
        }
        if (ans == -1) {
            ans = last++;
        }
        id[i] = ans;
    }

    cout << "0 ";
    for(int i = 1; i <= n; i++) {
        cout << id[i] << " ";
    }
    fflush(stdout);
    return 0;
}
//~ check for overflows
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 364 KB Integer 13 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 364 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 364 KB Output is correct
2 Incorrect 17 ms 364 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 492 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 364 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -