# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
738436 | LucaGreg | Carnival (CEOI14_carnival) | C++14 | 24 ms | 208 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;
#define pb push_back
#define ff first
#define ss second
#define int long long int
const int INF = 2000000000000000;
const int mod = 1000000007;
int marc[210];
int n;
int bb(int id, int ini, int fim){
vector<int> query;
for(int i=ini;i<=fim;i++) if(marc[i]==0) query.pb(i);
if(query.empty()) return -1;
cout<<query.size()<<" ";
for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
cout<<"\n";
cout.flush();
int qtd; cin>>qtd;
query.pb(id);
cout<<query.size()<<" ";
for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
cout<<"\n";
cout.flush();
int qtdId; cin>>qtdId;
if(qtdId>qtd) return -1;
while(ini<fim){
query.clear();
int m = (ini + fim)/2;
for(int i=ini;i<=m;i++) if(marc[i]==0) query.pb(i);
if(query.empty()){
ini = m + 1;
continue;
}
int auxQtd;
if((int)query.size()>1){
cout<<query.size()<<" ";
for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
cout<<"\n";
cout.flush();
cin>>auxQtd;
}else{
auxQtd = 1;
}
query.pb(id);
cout<<query.size()<<" ";
for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
cout<<"\n";
cout.flush();
int auxQtdId; cin>>auxQtdId;
if(auxQtdId>auxQtd) ini = m + 1;
else fim = m;
}
return fim;
}
main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(0);
cin>>n;
int curType = 1;
for(int i=1;i<=n;i++){
if(marc[i]!=0) continue;
marc[i] = curType;
while(true){
int id = bb(i, i + 1, n);
if(id==-1) break;
marc[id] = curType;
}
curType++;
}
cout<<0<<" ";
for(int i=1;i<=n;i++) cout<<marc[i]<<" ";
cout<<"\n";
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... |