Submission #320752

# Submission time Handle Problem Language Result Execution time Memory
320752 2020-11-09T18:24:07 Z gustason Carnival (CEOI14_carnival) C++17
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
    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 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -