Submission #320755

#TimeUsernameProblemLanguageResultExecution timeMemory
320755gustasonCarnival (CEOI14_carnival)C++14
0 / 100
26 ms384 KiB
#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) {
            //cout << L << " " << R << "\n\n\n";
            int mid = ceil((double) (L + R) / 2);

            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;
            } else {
                ans = L;
                L = mid + 1;
            }
        }

        cout << "2 " << i << " " << id[ans] << " ";
        fflush(stdout);
        int check;
        cin >> check;
        if (check == 2) {
            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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...