| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 778644 | Sandarach151 | Carnival (CEOI14_carnival) | C++17 | 16 ms | 312 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int getNum(vector<int> vect){
	if(vect.size()==1){
		return 1;
	}
    cout << vect.size();
    for(int i=0; i<vect.size(); i++){
        cout << ' ' << vect[i];
    }
    cout << endl;
    int a;
    cin >> a;
    return a;
}
vector<int> func(int cur, vector<int> vect){ // vect exculdes cur
    if(vect.size()==1){
        return vect;
    }
    else{
        int mid = vect.size()/2;
        vector<int> temp1, temp2, ans1, ans2;
        for(int i=0; i<mid; i++){
            temp1.push_back(vect[i]);
        }
        for(int i=mid; i<vect.size(); i++){
            temp2.push_back(vect[i]);
        }
        int a = getNum(temp1);
        temp1.push_back(cur);
        int b = getNum(temp1);
        if(b==a){
            temp1.pop_back();
            ans1 = func(cur, temp1);
        }
        int c = getNum(temp2);
        temp2.push_back(cur);
        int d = getNum(temp2);
        if(c==d){
            temp2.pop_back();
            ans2 = func(cur, temp2);
        }
        for(int i=0; i<ans2.size(); i++){
            ans1.push_back(ans2[i]);
        }
        return ans1;
    }
}
int main(){
    int n;
    cin >> n;
    vector<int> vect(n);
    for(int i=1; i<=n; i++){
        vect[i-1]=i;
    }
    vector<int> ans(n);
    int pos = 1;
    while(vect.size()>0){
        if(vect.size()==1){
            ans[vect[0]-1]=pos;
            break;
        }
        else{
            ans[vect[0]-1]=pos;
            int cur = vect[0];
            vector<int> temp;
            for(int i=1; i<vect.size(); i++){
                temp.push_back(vect[i]);
            }
            int a = getNum(temp);
            temp.push_back(vect[0]);
            int b = getNum(temp);
            temp.pop_back();
            if(a==b){
                vector<int> temp2 = func(cur, temp);
                for(int i=0; i<temp2.size(); i++){
                    ans[temp2[i]-1]=pos;
                    for(int j=0; j<vect.size(); j++){
                        if(vect[j]==temp2[i]){
                            vect.erase(vect.begin()+j);
                            break;
                        }
                    }
                }
                vect.erase(vect.begin());
                pos++;
            }
            else{
                vect.erase(vect.begin());
                pos++;
            }
        }
    }
    cout << 0;
    for(int i=0; i<n; i++){
		cout << ' ' << ans[i];
	}
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
