#include <bits/stdc++.h>
#include "library.h"
using namespace std;
int n;
/*int Query( vector<int> v ) {
for( int x : v ) printf("%d ",x);
printf("\n");
int c;
scanf("%d",&c);
return c;
}*/
int ask( vector<int> v ) {
vector<int> vec(n);
for( int &x : vec ) x = 0;
for( int x : v ) vec[x-1] = 1;
return Query( vec );
}
void eras( vector<int> &v, int i ) {
vector<int>::iterator it;
for( it = v.begin() ; it != v.end() ; it++ ) if( *it == i ) break;
v.erase( it );
}
void Solve( int n_ )
{
n = n_;
vector<int> ans(n);
vector<int> left;
for( int i = 1 ; i <= n ; i++ ) left.emplace_back( i );
for( int i = 1 ; i <= n ; i++ ) {
vector<int> v;
for( int j = 1 ; j <= n ; j++ ) if( i != j ) v.emplace_back( j );
if( ask( v ) == 1 ) {
ans[0] = i;
eras( left, i );
break ;
}
}
/*for( int i = 0 ; i < left.size() ; i++ ) printf("%d ",left[i]);
printf("\n");*/
for( int i = 1 ; i < n ; i++ ) {
int l = 0, r = left.size() - 1;
while( l < r ) {
int m = l + r >> 1;
vector<int> vv;
for( int j = 0 ; j <= m ; j++ ) vv.emplace_back( left[j] );
for( int j = 0 ; j < i ; j++ ) vv.emplace_back( ans[j] );
int a = vv.size() - ask( vv );
eras( vv, ans[i-1] );
int b = vv.size() - ask( vv );
if( a - b == 2 || ( i == 1 && a-b == 1 ) ) r = m;
else l = m + 1;
}
ans[i] = left[l];
eras( left, ans[i] );
//printf("ans[%d] : %d\n",i,ans[i]);
}
Answer( ans );
//for( int i = 0 ; i < n ; i++ ) printf("%d ",ans[i]);
}
/*int main()
{
int nn;
scanf("%d",&nn);
solve( nn );
}*/
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:49:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = l + r >> 1;
~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
53 ms |
384 KB |
# of queries: 2433 |
3 |
Correct |
50 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
38 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
48 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
56 ms |
384 KB |
# of queries: 2553 |
7 |
Correct |
52 ms |
256 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
384 KB |
# of queries: 2402 |
9 |
Correct |
46 ms |
256 KB |
# of queries: 2512 |
10 |
Correct |
31 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
384 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 73 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 187 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
53 ms |
384 KB |
# of queries: 2433 |
3 |
Correct |
50 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
38 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
48 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
56 ms |
384 KB |
# of queries: 2553 |
7 |
Correct |
52 ms |
256 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
384 KB |
# of queries: 2402 |
9 |
Correct |
46 ms |
256 KB |
# of queries: 2512 |
10 |
Correct |
31 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
384 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 73 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 187 |
17 |
Correct |
563 ms |
384 KB |
# of queries: 18008 |
18 |
Correct |
551 ms |
384 KB |
# of queries: 17231 |
19 |
Correct |
572 ms |
256 KB |
# of queries: 17451 |
20 |
Correct |
507 ms |
256 KB |
# of queries: 16277 |
21 |
Correct |
471 ms |
384 KB |
# of queries: 15362 |
22 |
Correct |
548 ms |
256 KB |
# of queries: 17617 |
23 |
Correct |
552 ms |
256 KB |
# of queries: 17170 |
24 |
Correct |
189 ms |
256 KB |
# of queries: 7885 |
25 |
Correct |
538 ms |
384 KB |
# of queries: 17118 |
26 |
Correct |
478 ms |
256 KB |
# of queries: 15989 |
27 |
Correct |
194 ms |
384 KB |
# of queries: 7994 |
28 |
Correct |
515 ms |
256 KB |
# of queries: 17935 |
29 |
Correct |
523 ms |
256 KB |
# of queries: 17915 |
30 |
Correct |
533 ms |
384 KB |
# of queries: 17935 |