#include <cstdio>
#include <vector>
#include "library.h"
#define PB push_back
using namespace std;
typedef vector < int > vi;
int n;
bool provjeri(vi skp, int x){
vi glp(n);
for(int y : skp)
glp[y] = 1;
int ans1 = Query(glp);
glp[x] = 1;
int ans2 = Query(glp);
return ans1 == ans2;
}
int pocetak(){
vi glp(n);
for(int i = 0;i < n;i++)
glp[i] = 1;
for(int i = 0;i < n;i++){
glp[i] = 0;
if(Query(glp) == 1)
return i;
glp[i] = 1;
}
}
int nadi(vi skp,int x){
int ret = -1;
for(int i = 10;i >= 0;i--){
if((ret + (1 << i)) >= (int)skp.size())
continue;
vi tmp;
for(int j = 0;j <= (ret + (1 << i));j++)
tmp.PB(skp[j]);
if(!provjeri(tmp, x))
ret += (1 << i);
}
return skp[ret + 1];
}
void Solve(int nn){
if(n == 1){
Answer({1}); return;
}
n = nn;
int st = pocetak();
vi tren, ret;
ret.PB(st);
for(int i = 0;i < n;i++)
if(st != i) tren.PB(i);
for(int i = 1;i < n;i++){
ret.PB(nadi(tren, ret.back()));
for(int j = 0;j < n - i;j++){
if(tren[j] == ret.back()){
tren.erase(tren.begin() + j);
break;
}
}
}
for(int &x : ret) x++;
Answer(ret);
}
Compilation message
library.cpp: In function 'int pocetak()':
library.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
256 KB |
# of queries: 2507 |
2 |
Correct |
45 ms |
256 KB |
# of queries: 2505 |
3 |
Correct |
45 ms |
256 KB |
# of queries: 2770 |
4 |
Correct |
49 ms |
256 KB |
# of queries: 2695 |
5 |
Correct |
42 ms |
256 KB |
# of queries: 2602 |
6 |
Correct |
48 ms |
256 KB |
# of queries: 2675 |
7 |
Correct |
48 ms |
256 KB |
# of queries: 2698 |
8 |
Correct |
43 ms |
256 KB |
# of queries: 2544 |
9 |
Correct |
43 ms |
256 KB |
# of queries: 2660 |
10 |
Correct |
27 ms |
256 KB |
# of queries: 1566 |
11 |
Incorrect |
5 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
5 ms |
256 KB |
# of queries: 3 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 8 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 11 |
15 |
Correct |
6 ms |
256 KB |
# of queries: 89 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 213 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
256 KB |
# of queries: 2507 |
2 |
Correct |
45 ms |
256 KB |
# of queries: 2505 |
3 |
Correct |
45 ms |
256 KB |
# of queries: 2770 |
4 |
Correct |
49 ms |
256 KB |
# of queries: 2695 |
5 |
Correct |
42 ms |
256 KB |
# of queries: 2602 |
6 |
Correct |
48 ms |
256 KB |
# of queries: 2675 |
7 |
Correct |
48 ms |
256 KB |
# of queries: 2698 |
8 |
Correct |
43 ms |
256 KB |
# of queries: 2544 |
9 |
Correct |
43 ms |
256 KB |
# of queries: 2660 |
10 |
Correct |
27 ms |
256 KB |
# of queries: 1566 |
11 |
Incorrect |
5 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
5 ms |
256 KB |
# of queries: 3 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 8 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 11 |
15 |
Correct |
6 ms |
256 KB |
# of queries: 89 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 213 |
17 |
Correct |
461 ms |
384 KB |
# of queries: 18516 |
18 |
Correct |
439 ms |
376 KB |
# of queries: 17631 |
19 |
Correct |
424 ms |
408 KB |
# of queries: 17883 |
20 |
Correct |
403 ms |
384 KB |
# of queries: 16717 |
21 |
Correct |
367 ms |
384 KB |
# of queries: 15814 |
22 |
Correct |
445 ms |
376 KB |
# of queries: 18067 |
23 |
Correct |
422 ms |
384 KB |
# of queries: 17622 |
24 |
Correct |
152 ms |
384 KB |
# of queries: 8145 |
25 |
Correct |
431 ms |
376 KB |
# of queries: 17542 |
26 |
Correct |
377 ms |
376 KB |
# of queries: 16391 |
27 |
Correct |
121 ms |
408 KB |
# of queries: 8268 |
28 |
Correct |
390 ms |
384 KB |
# of queries: 17955 |
29 |
Correct |
422 ms |
384 KB |
# of queries: 17935 |
30 |
Correct |
434 ms |
384 KB |
# of queries: 17955 |