#include<bits/stdc++.h>
#include"library.h"
using namespace std ;
const int N = 1e3 ;
//int Query(vector<int>& v)
//{
// int num ;
// cout << "? " ;
// for(int i : v)
// cout << i << ' ' ;
// cout << '\n' ;
// cin >> num ;
// return num ;
//}
//void Answer(vector<int>& res)
//{
// cout << "! " ;
// for(int i : res)
// cout << i << ' ' ;
// exit(0) ;
//}
vector<int> qr, ans, v[N + 1] ;
void dfs(int city, int last)
{
ans.push_back(city) ;
for(int i : v[city])
{
if(i == last)
continue ;
dfs(i, city) ;
}
}
int get_kol(vector<int> qr)
{
int l = 0, r = 0, kol = 0 ;
for(int i = 0 ; i < qr.size() ; i++)
if(qr[i])
{
if(!l)l = i + 1 ;
r = i + 1 ;
}
for(int i = 0 ; i < qr.size() ; i++)
{
if(!qr[i])
continue ;
for(int j : v[i + 1])
if(l <= j && j <= r)
kol++ ;
}
return kol / 2 ;
}
void Solve(int n)
{
for(int i = 1 ; i <= n ; i++)
qr.push_back(0) ;
for(int i = 1 ; i < n ; i++)
{
int l1 = 0, r1 = n + 1, l2 = 0, r2 ;
bool flag = 0 ;
while(l1 + 1 < r1)
{
int mid = (l1 + r1) >> 1, num ;
for(int j = 1 ; j <= mid ; j++)
qr[j - 1] = 1 ;
num = get_kol(qr) ;
// cout<<"1+ "<<l1<<' '<<r1 << ' ' << num <<'\n' ;
if(Query(qr) != mid - get_kol(qr))
r1 = mid ;
else
l1 = mid ;
for(int j = 1 ; j <= mid ; j++)
qr[j - 1] = 0 ;
}
r2 = r1 ;
while(l2 + 1 < r2)
{
int mid = (l2 + r2) >> 1, num ;
for(int j = mid ; j <= r1 ; j++)
qr[j - 1] = 1 ;
num = get_kol(qr) ;
// cout<<"2+ "<<l2<<' '<<r2 << ' ' << num <<'\n' ;
if(Query(qr) != (r1 - mid + 1) - get_kol(qr))
l2 = mid ;
else
r2 = mid ;
for(int j = mid ; j <= r1 ; j++)
qr[j - 1] = 0 ;
}
// cout << l2 << '-' << r1 << '\n' ;
v[l2].push_back(r1) ;
v[r1].push_back(l2) ;
}
if(n == 1)
ans.push_back(1) ;
for(int i = 1 ; i <= n ; i++)
if(v[i].size() == 1)
{
dfs(i, 0) ;
break ;
}
Answer(ans) ;
}
//signed main()
//{
// int n ;
// cin >> n ;
// Solve(n) ;
// return 0 ;
//}
Compilation message
library.cpp: In function 'int get_kol(std::vector<int>)':
library.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i = 0 ; i < qr.size() ; i++)
| ~~^~~~~~~~~~~
library.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i = 0 ; i < qr.size() ; i++)
| ~~^~~~~~~~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:62:39: warning: variable 'num' set but not used [-Wunused-but-set-variable]
62 | int mid = (l1 + r1) >> 1, num ;
| ^~~
library.cpp:77:39: warning: variable 'num' set but not used [-Wunused-but-set-variable]
77 | int mid = (l2 + r2) >> 1, num ;
| ^~~
library.cpp:59:14: warning: unused variable 'flag' [-Wunused-variable]
59 | bool flag = 0 ;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
208 KB |
# of queries: 2797 |
2 |
Correct |
35 ms |
312 KB |
# of queries: 2784 |
3 |
Correct |
23 ms |
208 KB |
# of queries: 2931 |
4 |
Correct |
40 ms |
308 KB |
# of queries: 2935 |
5 |
Correct |
34 ms |
316 KB |
# of queries: 2936 |
6 |
Correct |
39 ms |
308 KB |
# of queries: 2938 |
7 |
Correct |
40 ms |
308 KB |
# of queries: 2924 |
8 |
Correct |
39 ms |
316 KB |
# of queries: 2791 |
9 |
Correct |
30 ms |
312 KB |
# of queries: 2926 |
10 |
Correct |
22 ms |
312 KB |
# of queries: 1719 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 3 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 13 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 103 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 238 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
208 KB |
# of queries: 2797 |
2 |
Correct |
35 ms |
312 KB |
# of queries: 2784 |
3 |
Correct |
23 ms |
208 KB |
# of queries: 2931 |
4 |
Correct |
40 ms |
308 KB |
# of queries: 2935 |
5 |
Correct |
34 ms |
316 KB |
# of queries: 2936 |
6 |
Correct |
39 ms |
308 KB |
# of queries: 2938 |
7 |
Correct |
40 ms |
308 KB |
# of queries: 2924 |
8 |
Correct |
39 ms |
316 KB |
# of queries: 2791 |
9 |
Correct |
30 ms |
312 KB |
# of queries: 2926 |
10 |
Correct |
22 ms |
312 KB |
# of queries: 1719 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
208 KB |
# of queries: 3 |
13 |
Correct |
0 ms |
208 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 13 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 103 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 238 |
17 |
Correct |
415 ms |
348 KB |
# of queries: 19266 |
18 |
Correct |
493 ms |
336 KB |
# of queries: 19022 |
19 |
Correct |
454 ms |
344 KB |
# of queries: 19225 |
20 |
Correct |
379 ms |
460 KB |
# of queries: 18016 |
21 |
Correct |
348 ms |
336 KB |
# of queries: 16925 |
22 |
Correct |
451 ms |
336 KB |
# of queries: 19268 |
23 |
Correct |
391 ms |
340 KB |
# of queries: 19242 |
24 |
Correct |
156 ms |
324 KB |
# of queries: 8893 |
25 |
Correct |
387 ms |
336 KB |
# of queries: 18813 |
26 |
Correct |
372 ms |
340 KB |
# of queries: 17601 |
27 |
Correct |
141 ms |
320 KB |
# of queries: 8861 |
28 |
Correct |
411 ms |
328 KB |
# of queries: 18945 |
29 |
Correct |
381 ms |
340 KB |
# of queries: 18924 |
30 |
Correct |
376 ms |
312 KB |
# of queries: 18945 |