Submission #1188671

#TimeUsernameProblemLanguageResultExecution timeMemory
1188671njoop사육제 (CEOI14_carnival)C++20
0 / 100
13 ms428 KiB
#include <bits/stdc++.h>

using namespace std;

int n, ans[200], c1, c2, call;
map<int, int> linked, mp;
set<int> s;

int ask(vector<int> v) {
    int c;
    cout << v.size() << " ";
    for(auto i: v) {
        cout << i << " ";
    }
    cout << endl;
    cin >> c;
    return c;
}

int main() {
    vector<int> v;
    cin >> n;
    for(int i=1; i<=n; i++) {
        ans[i] = -1;
    }
    int pr=0;
    for(int i=1; i<=n/2; i++) {
        v.clear();
        for(int j=1; j<=i; j++) v.push_back(j);
        int c = ask(v);
        if(c != pr) {
            pr = c;
            linked[c] = i;
            ans[i] = pr;
            s.insert(pr);
        }
    }
    c1 = pr;
    pr = 0;
    for(int i=n/2+1; i<=n; i++) {
        v.clear();
        for(int j=n/2+1; j<=i; j++) v.push_back(j);
        int c = ask(v);
        if(c != pr) {
            pr = c;
            linked[c+300] = i;
            ans[i] = pr+300;
        }
    }
    c2 = pr;
    call = c1;
    for(int i=1; i<=c1; i++) {
        v.clear();
        for(int j=n/2+1; j<=n; j++) v.push_back(j);
        v.push_back(linked[i]);
        int ct = ask(v);
        if(ct > c2) s.insert(i);
    }
    for(int i=1; i<=c2; i++) {
        int t = -1;
        for(auto j: s) {
            v = {linked[j], linked[i+300]};
            int t = ask(v);
            if(t == 1) {
                mp[i+300] = j;
                t = j;
                goto jump;
            }
        }
        jump:;
        if(t != -1 && s.find(t) != s.end()) s.erase(t);  
        if(mp[i+300] == 0) {
            call++;
            mp[i+300] = call;
        }
    }
    for(int i=1; i<=n/2; i++) {
        if(ans[i] == -1) {
            for(int j=1; j<=c1; j++) {
                v = {i, linked[j]};
                if(ask(v) == 1) {
                    ans[i] = j;
                }
            }
        }
    }
    for(int i=n/2+1; i<=n; i++) {
        if(ans[i] == -1) {
            for(int j=1; j<=c2; j++) {
                v = {i, linked[mp[j+300]]};
                if(ask(v) == 1) {
                    ans[i] = mp[j+300];
                }
            }
        }
    }
    cout << 0;
    for(int i=1; i<=n; i++) {
        if(ans[i] > 300) ans[i] = mp[ans[i]];
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}
#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...