# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724756 | hyakup | Carnival (CEOI14_carnival) | C++17 | 8 ms | 292 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;
const int maxn = 160;
int v[maxn];
int cont;
vector<int> lista;
bool queryInit( int id ){
cout << lista.size() + 1 << " ";
for( int x : lista ) cout << x << " ";
cout << id << endl;
cout.flush();
int resp; cin >> resp;
return ( resp == lista.size() + 1 );
}
bool query( int l, int r, int id ){
cout << r - l + 2 << " ";
for( int i = l; i <= r; i++ ) cout << lista[i] << " ";
cout << id << endl;
cout.flush();
int resp; cin >> resp;
return ( resp != r - l + 2 );
}
void solve( int id ){
if( queryInit(id) ){ v[id] = ++cont; lista.push_back(id); return; }
int l = 0, r = lista.size() - 1;
while( l < r ){
int mid = ( l + r )/2;
if( query( l, mid, id ) ) r = mid;
else l = mid + 1;
}
v[id] = v[lista[r]];
}
int main(){
int n; cin >> n;
for( int i = 1; i <= n; i++ ) solve(i);
cout << 0 << " ";
for( int i = 1; i <= n; i++ ) cout << v[i] << " ";
}
// 1 2 1 3 2
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... |