# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
80718 |
2018-10-22T04:33:08 Z |
admin |
Library (JOI18_library) |
C++17 |
|
455 ms |
648 KB |
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
int n;
int ask(vector<int> &V){
return Query(V);
}
int find1(int n){
if(n==1) return 0;
vector<int> M(n);
for(int i=0; i<n; i++) M[i]=1;
for(int i=0; i<n; i++){
M[i]=0;
if(ask(M)==1) return i;
M[i]=1;
}
return 0;
}
vector<int> X, Y;
vector<bool> done;
int findnext(int s, int e, vector<int> &V){
if(s==e) return V[s];
if(s>e) return 0;
int m=(s+e)/2;
for(int i=s; i<=m; i++) X[V[i]]=Y[V[i]]=1;
int a=ask(X), b=ask(Y);
for(int i=s; i<=m; i++) X[V[i]]=Y[V[i]]=0;
if(a==b) return findnext(s, m, V);
else return findnext(m+1, e, V);
}
void Solve(int N){
n=N;
X.resize(n, 0);
Y.resize(n, 0);
done.resize(n, false);
vector<int> ans(n);
int p=find1(n);
X[p]=1;
ans[0]=p+1;
done[p]=true;
for(int i=1; i<n; i++){
vector<int> V;
for(int i=0; i<n; i++) if(!done[i]) V.push_back(i);
int nxt=findnext(0, V.size()-1, V);
ans[i]=nxt+1;
done[nxt]=true;
X[nxt]=1;
}
Answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
248 KB |
# of queries: 2387 |
2 |
Correct |
30 ms |
452 KB |
# of queries: 2433 |
3 |
Correct |
37 ms |
452 KB |
# of queries: 2638 |
4 |
Correct |
39 ms |
576 KB |
# of queries: 2593 |
5 |
Correct |
40 ms |
648 KB |
# of queries: 2504 |
6 |
Correct |
29 ms |
648 KB |
# of queries: 2553 |
7 |
Correct |
32 ms |
648 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
648 KB |
# of queries: 2402 |
9 |
Correct |
31 ms |
648 KB |
# of queries: 2512 |
10 |
Correct |
18 ms |
648 KB |
# of queries: 1478 |
11 |
Correct |
2 ms |
648 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
648 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
648 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
648 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
648 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
648 KB |
# of queries: 187 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
248 KB |
# of queries: 2387 |
2 |
Correct |
30 ms |
452 KB |
# of queries: 2433 |
3 |
Correct |
37 ms |
452 KB |
# of queries: 2638 |
4 |
Correct |
39 ms |
576 KB |
# of queries: 2593 |
5 |
Correct |
40 ms |
648 KB |
# of queries: 2504 |
6 |
Correct |
29 ms |
648 KB |
# of queries: 2553 |
7 |
Correct |
32 ms |
648 KB |
# of queries: 2568 |
8 |
Correct |
43 ms |
648 KB |
# of queries: 2402 |
9 |
Correct |
31 ms |
648 KB |
# of queries: 2512 |
10 |
Correct |
18 ms |
648 KB |
# of queries: 1478 |
11 |
Correct |
2 ms |
648 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
648 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
648 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
648 KB |
# of queries: 7 |
15 |
Correct |
2 ms |
648 KB |
# of queries: 73 |
16 |
Correct |
4 ms |
648 KB |
# of queries: 187 |
17 |
Correct |
430 ms |
648 KB |
# of queries: 18008 |
18 |
Correct |
375 ms |
648 KB |
# of queries: 17231 |
19 |
Correct |
402 ms |
648 KB |
# of queries: 17451 |
20 |
Correct |
377 ms |
648 KB |
# of queries: 16277 |
21 |
Correct |
339 ms |
648 KB |
# of queries: 15362 |
22 |
Correct |
384 ms |
648 KB |
# of queries: 17617 |
23 |
Correct |
363 ms |
648 KB |
# of queries: 17170 |
24 |
Correct |
160 ms |
648 KB |
# of queries: 7885 |
25 |
Correct |
383 ms |
648 KB |
# of queries: 17118 |
26 |
Correct |
332 ms |
648 KB |
# of queries: 15989 |
27 |
Correct |
108 ms |
648 KB |
# of queries: 7994 |
28 |
Correct |
411 ms |
648 KB |
# of queries: 17935 |
29 |
Correct |
380 ms |
648 KB |
# of queries: 17915 |
30 |
Correct |
455 ms |
648 KB |
# of queries: 17935 |