# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385679 | monus1042 | Carnival (CEOI14_carnival) | C++17 | 2 ms | 364 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;
typedef pair<int,int> ii;
#define pb push_back
const int NAX = 200;
int n;
int main(){
cin>>n;
map<int, vector<int> > g;
int curr=1;
g[1].pb(1);
for (int i=2; i<=n; i++){
cout<<i<<' ';
for (auto j=g.begin(); j!=g.end(); j++){
for (int k=0; k<j->second.size(); k++){
cout<<j->second[k]<<' ';
}
}
cout<<endl;
int ans; cin>>ans;
if (ans>curr){
curr++;
g[curr].pb(i);
}else{ // it's equal
vector<ii> aux; // index, color
for (auto j=g.begin(); j!=g.end(); j++) aux.pb(ii(j->second[0], j->first));
int m=aux.size();
int lo=m-1, hi=-1;
while(lo-1!=hi){
int mid=(lo+hi)/2;
vector<int> show;
for (int k=mid; k<m; k++){
show.pb(aux[k].first);
}
cout<<show.size() + 1<<' ';
for (int k=0; k<show.size(); k++) cout<<show[k]<<' ';
cout<<i;
cout<<endl;
int an; cin>>an;
if (an==(int)show.size() + 1) lo=mid;
else hi=mid;
}
int mid=lo;
vector<int> show;
for (int k=mid; k<m; k++){
show.pb(aux[k].first);
}
cout<<show.size() + 1<<' ';
for (int k=0; k<show.size(); k++) cout<<show[k]<<' ';
cout<<i;
cout<<endl;
int an; cin>>an;
if (an==(int)show.size() + 1) lo--;
g[aux[lo].second].pb(i);
}
}
vector<int> ans(NAX);
for (auto i=g.begin(); i!=g.end(); i++){
for (int j=0; j<i->second.size(); j++) ans[i->second[j]]=i->first;
}
cout<<0<<' ';
for (int i=1; i<=n; i++) cout<<ans[i]<<' ';
cout<<endl;
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... |