#include <cstdio>
#include <algorithm>
#include <vector>
#include <assert.h>
#include "library.h"
using namespace std;
vector<int> adj[1002];
int U[1002];
void Solve(int N)
{
vector<int> M(N);
M[0] = 1;
int P = 1;
for(int i = 1; i < N; i++) {
int l = 0, r = i-1;
M[i] = 1;
int Q = Query(M);
if(P < Q) { P = Q; continue; }
while(l < r)
{
vector<int> v(N);
int mid = (l + r)/2;
for(int j=0;j<=mid;j++) v[j] = 1;
int A, B;
A = Query(v);
v[i] = 1;
B = Query(v);
if(A >= B) r = mid;
else l = mid+1;
}
adj[i].push_back(l);
adj[l].push_back(i);
if(P == Q) continue;
l = 0, r = i-1;
while(l < r)
{
vector<int> v(N);
int mid = (l + r)/2;
for(int j=0;j<=mid;j++) v[j] = 1;
int A, B;
A = Query(v);
v[i] = 1;
B = Query(v);
if(A > B) r = mid;
else l = mid+1;
}
adj[l].push_back(i);
adj[i].push_back(l);
P = Q;
}
vector<int> res(N);
int st = -1;
for(int i=0;i<N;i++) assert(adj[i].size() <= 2);
for(int i=0;i<N;i++) if(adj[i].size() == 1) { st = i; break; }
assert(st >= 0);
for(int i=0,now=st;i<N;i++)
{
assert(!U[now]);
res[i] = now+1;
U[now] = 1;
for(int nxt : adj[now])
{
if(!U[nxt])
{
now = nxt;
break;
}
}
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
200 KB |
# of queries: 2853 |
2 |
Correct |
53 ms |
320 KB |
# of queries: 2820 |
3 |
Correct |
40 ms |
324 KB |
# of queries: 2973 |
4 |
Correct |
54 ms |
308 KB |
# of queries: 2967 |
5 |
Correct |
50 ms |
200 KB |
# of queries: 2953 |
6 |
Correct |
43 ms |
320 KB |
# of queries: 2963 |
7 |
Correct |
46 ms |
324 KB |
# of queries: 2997 |
8 |
Correct |
43 ms |
304 KB |
# of queries: 2840 |
9 |
Correct |
49 ms |
200 KB |
# of queries: 2996 |
10 |
Correct |
30 ms |
320 KB |
# of queries: 1750 |
11 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
200 KB |
# of queries: 2853 |
2 |
Correct |
53 ms |
320 KB |
# of queries: 2820 |
3 |
Correct |
40 ms |
324 KB |
# of queries: 2973 |
4 |
Correct |
54 ms |
308 KB |
# of queries: 2967 |
5 |
Correct |
50 ms |
200 KB |
# of queries: 2953 |
6 |
Correct |
43 ms |
320 KB |
# of queries: 2963 |
7 |
Correct |
46 ms |
324 KB |
# of queries: 2997 |
8 |
Correct |
43 ms |
304 KB |
# of queries: 2840 |
9 |
Correct |
49 ms |
200 KB |
# of queries: 2996 |
10 |
Correct |
30 ms |
320 KB |
# of queries: 1750 |
11 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |