# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1085830 | contest_alt | Carnival (CEOI14_carnival) | C++17 | 5 ms | 596 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 <stdio.h>
#include <vector>
#include <algorithm>
const int MAXN = 150;
int query( const std::vector<int> &indici ) {
printf( "%d", (int)indici.size() );
for( int x : indici )
printf( " %d", x + 1 );
printf( "\n" );
fflush( stdout );
int ret;
scanf( "%d", &ret );
return ret;
}
int non_uniq( const std::vector<int> &indici ) {
return (int)indici.size() - query( indici );
}
int col[MAXN];
int main() {
int n;
scanf( "%d", &n );
std::vector<int> reps;
std::vector<int> others;
for( int i = 0; i < n; i++ ){
reps.push_back( i );
if( non_uniq( reps ) ){
reps.pop_back();
others.push_back( i );
}
}
for( int i = 0; i < (int)reps.size(); i++ )
col[reps[i]] = i + 1;
for( int idx : others ) {
int st = 0, dr = (int)reps.size();
while( dr - st > 1 ){
int mij = (st + dr) >> 1;
std::vector<int> left_query(1, idx);
for( int i = st; i < mij; i++ )
left_query.push_back( reps[i] );
if( non_uniq( left_query ) ) // repreat found => go in left half
dr = mij;
else
st = mij;
}
col[idx] = col[reps[st]];
}
printf( "0" );
for( int i = 0; i < n; i++ )
printf( " %d", col[i] );
printf( "\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... |