# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
58186 |
2018-07-17T06:16:00 Z |
Diuven |
Library (JOI18_library) |
C++11 |
|
734 ms |
600 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 |
41 ms |
376 KB |
Output is correct |
2 |
Correct |
33 ms |
376 KB |
Output is correct |
3 |
Correct |
50 ms |
388 KB |
Output is correct |
4 |
Correct |
50 ms |
568 KB |
Output is correct |
5 |
Correct |
36 ms |
568 KB |
Output is correct |
6 |
Correct |
48 ms |
568 KB |
Output is correct |
7 |
Correct |
71 ms |
568 KB |
Output is correct |
8 |
Correct |
46 ms |
568 KB |
Output is correct |
9 |
Correct |
35 ms |
568 KB |
Output is correct |
10 |
Correct |
32 ms |
580 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
1 ms |
580 KB |
Output is correct |
13 |
Correct |
2 ms |
580 KB |
Output is correct |
14 |
Correct |
2 ms |
580 KB |
Output is correct |
15 |
Correct |
2 ms |
580 KB |
Output is correct |
16 |
Correct |
3 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
376 KB |
Output is correct |
2 |
Correct |
33 ms |
376 KB |
Output is correct |
3 |
Correct |
50 ms |
388 KB |
Output is correct |
4 |
Correct |
50 ms |
568 KB |
Output is correct |
5 |
Correct |
36 ms |
568 KB |
Output is correct |
6 |
Correct |
48 ms |
568 KB |
Output is correct |
7 |
Correct |
71 ms |
568 KB |
Output is correct |
8 |
Correct |
46 ms |
568 KB |
Output is correct |
9 |
Correct |
35 ms |
568 KB |
Output is correct |
10 |
Correct |
32 ms |
580 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
1 ms |
580 KB |
Output is correct |
13 |
Correct |
2 ms |
580 KB |
Output is correct |
14 |
Correct |
2 ms |
580 KB |
Output is correct |
15 |
Correct |
2 ms |
580 KB |
Output is correct |
16 |
Correct |
3 ms |
580 KB |
Output is correct |
17 |
Correct |
568 ms |
600 KB |
Output is correct |
18 |
Correct |
480 ms |
600 KB |
Output is correct |
19 |
Correct |
582 ms |
600 KB |
Output is correct |
20 |
Correct |
603 ms |
600 KB |
Output is correct |
21 |
Correct |
476 ms |
600 KB |
Output is correct |
22 |
Correct |
521 ms |
600 KB |
Output is correct |
23 |
Correct |
734 ms |
600 KB |
Output is correct |
24 |
Correct |
227 ms |
600 KB |
Output is correct |
25 |
Correct |
507 ms |
600 KB |
Output is correct |
26 |
Correct |
442 ms |
600 KB |
Output is correct |
27 |
Correct |
171 ms |
600 KB |
Output is correct |
28 |
Correct |
566 ms |
600 KB |
Output is correct |
29 |
Correct |
509 ms |
600 KB |
Output is correct |
30 |
Correct |
492 ms |
600 KB |
Output is correct |