제출 #320757

#제출 시각아이디문제언어결과실행 시간메모리
320757gustason사육제 (CEOI14_carnival)C++17
0 / 100
21 ms364 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;
//    id[2] = 1;
//    id[3] = 1;
//    id[4] = 3;
//    id[5] = 2;
//    id[6] = 4;
    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 = L;
                L = mid + 1;
            } else {
                ans = R;
                R = mid - 1;
            }
        }

        cout << "2 " << i << " " << id[ans] << " ";
        fflush(stdout);
        int check;
        cin >> check;
        if (check == 2) {
            id[i] = last++;
        } else {
            id[i] = id[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...