#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){
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 |
46 ms |
384 KB |
# of queries: 2507 |
2 |
Correct |
41 ms |
256 KB |
# of queries: 2505 |
3 |
Correct |
45 ms |
256 KB |
# of queries: 2770 |
4 |
Correct |
45 ms |
256 KB |
# of queries: 2695 |
5 |
Correct |
40 ms |
408 KB |
# of queries: 2602 |
6 |
Correct |
44 ms |
256 KB |
# of queries: 2675 |
7 |
Correct |
46 ms |
512 KB |
# of queries: 2698 |
8 |
Correct |
41 ms |
256 KB |
# of queries: 2544 |
9 |
Correct |
46 ms |
384 KB |
# of queries: 2660 |
10 |
Correct |
26 ms |
384 KB |
# of queries: 1566 |
11 |
Incorrect |
4 ms |
384 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
384 KB |
# of queries: 3 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 8 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 11 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 89 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 213 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
384 KB |
# of queries: 2507 |
2 |
Correct |
41 ms |
256 KB |
# of queries: 2505 |
3 |
Correct |
45 ms |
256 KB |
# of queries: 2770 |
4 |
Correct |
45 ms |
256 KB |
# of queries: 2695 |
5 |
Correct |
40 ms |
408 KB |
# of queries: 2602 |
6 |
Correct |
44 ms |
256 KB |
# of queries: 2675 |
7 |
Correct |
46 ms |
512 KB |
# of queries: 2698 |
8 |
Correct |
41 ms |
256 KB |
# of queries: 2544 |
9 |
Correct |
46 ms |
384 KB |
# of queries: 2660 |
10 |
Correct |
26 ms |
384 KB |
# of queries: 1566 |
11 |
Incorrect |
4 ms |
384 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
384 KB |
# of queries: 3 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 8 |
14 |
Correct |
5 ms |
384 KB |
# of queries: 11 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 89 |
16 |
Correct |
7 ms |
384 KB |
# of queries: 213 |
17 |
Correct |
462 ms |
376 KB |
# of queries: 18516 |
18 |
Correct |
436 ms |
380 KB |
# of queries: 17631 |
19 |
Correct |
444 ms |
384 KB |
# of queries: 17883 |
20 |
Correct |
403 ms |
376 KB |
# of queries: 16717 |
21 |
Correct |
370 ms |
384 KB |
# of queries: 15814 |
22 |
Correct |
455 ms |
384 KB |
# of queries: 18067 |
23 |
Correct |
427 ms |
384 KB |
# of queries: 17622 |
24 |
Correct |
151 ms |
384 KB |
# of queries: 8145 |
25 |
Correct |
405 ms |
384 KB |
# of queries: 17542 |
26 |
Correct |
396 ms |
384 KB |
# of queries: 16391 |
27 |
Correct |
146 ms |
256 KB |
# of queries: 8268 |
28 |
Correct |
422 ms |
384 KB |
# of queries: 17955 |
29 |
Correct |
428 ms |
384 KB |
# of queries: 17935 |
30 |
Correct |
413 ms |
384 KB |
# of queries: 17955 |