#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int maxn = 1005;
vector<int> g[maxn], ans;
bool vis[maxn];
int n;
vector<pair<int, int> > e;
int count_edges(int l, int r)
{
int cnt = 0;
for (pair<int, int> i : e) cnt += (l <= i.first && i.second <= r);
return cnt;
}
bool extra_edge(int l, int r)
{
vector<int> ask(n, 0);
for (int i = l; i <= r; i++)
ask[i] = 1;
int e = r - l + 1 - Query(ask);
return e > count_edges(l, r);
}
void dfs(int u)
{
ans.push_back(u+1);
vis[u] = true;
for (int v : g[u]) if (!vis[v])
dfs(v);
}
void Solve(int N)
{
n = N;
for (int it = 0; it < n - 1; it++)
{
int li = 1, ri = n - 1;
while (li < ri)
{
int mi = (li + ri) >> 1;
if (extra_edge(0, mi)) ri = mi;
else li = mi + 1;
}
int lj = 0, rj = ri - 1;
while (lj < rj)
{
int mj = (lj + rj + 1) >> 1;
if (extra_edge(mj, ri)) lj = mj;
else rj = mj - 1;
}
e.push_back({ rj, ri });
g[ri].push_back(rj);
g[rj].push_back(ri);
}
for (int i = 0; i < n; i++) if (g[i].size() < 2)
{
dfs(i);
break;
}
Answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
308 KB |
# of queries: 2792 |
2 |
Correct |
51 ms |
200 KB |
# of queries: 2777 |
3 |
Correct |
53 ms |
200 KB |
# of queries: 2922 |
4 |
Correct |
38 ms |
316 KB |
# of queries: 2915 |
5 |
Correct |
46 ms |
300 KB |
# of queries: 2928 |
6 |
Correct |
46 ms |
200 KB |
# of queries: 2930 |
7 |
Correct |
46 ms |
200 KB |
# of queries: 2920 |
8 |
Correct |
46 ms |
200 KB |
# of queries: 2777 |
9 |
Correct |
50 ms |
200 KB |
# of queries: 2911 |
10 |
Correct |
23 ms |
300 KB |
# of queries: 1717 |
11 |
Correct |
0 ms |
200 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
200 KB |
# of queries: 0 |
13 |
Correct |
1 ms |
200 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
200 KB |
# of queries: 9 |
15 |
Correct |
2 ms |
200 KB |
# of queries: 99 |
16 |
Correct |
5 ms |
200 KB |
# of queries: 228 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
308 KB |
# of queries: 2792 |
2 |
Correct |
51 ms |
200 KB |
# of queries: 2777 |
3 |
Correct |
53 ms |
200 KB |
# of queries: 2922 |
4 |
Correct |
38 ms |
316 KB |
# of queries: 2915 |
5 |
Correct |
46 ms |
300 KB |
# of queries: 2928 |
6 |
Correct |
46 ms |
200 KB |
# of queries: 2930 |
7 |
Correct |
46 ms |
200 KB |
# of queries: 2920 |
8 |
Correct |
46 ms |
200 KB |
# of queries: 2777 |
9 |
Correct |
50 ms |
200 KB |
# of queries: 2911 |
10 |
Correct |
23 ms |
300 KB |
# of queries: 1717 |
11 |
Correct |
0 ms |
200 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
200 KB |
# of queries: 0 |
13 |
Correct |
1 ms |
200 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
200 KB |
# of queries: 9 |
15 |
Correct |
2 ms |
200 KB |
# of queries: 99 |
16 |
Correct |
5 ms |
200 KB |
# of queries: 228 |
17 |
Correct |
331 ms |
456 KB |
# of queries: 19283 |
18 |
Correct |
358 ms |
332 KB |
# of queries: 19027 |
19 |
Correct |
396 ms |
340 KB |
# of queries: 19254 |
20 |
Correct |
381 ms |
568 KB |
# of queries: 18004 |
21 |
Correct |
344 ms |
336 KB |
# of queries: 16924 |
22 |
Correct |
372 ms |
468 KB |
# of queries: 19268 |
23 |
Correct |
428 ms |
464 KB |
# of queries: 19228 |
24 |
Correct |
152 ms |
440 KB |
# of queries: 8882 |
25 |
Correct |
455 ms |
464 KB |
# of queries: 18812 |
26 |
Correct |
349 ms |
456 KB |
# of queries: 17594 |
27 |
Correct |
143 ms |
308 KB |
# of queries: 8847 |
28 |
Correct |
434 ms |
460 KB |
# of queries: 18932 |
29 |
Correct |
350 ms |
464 KB |
# of queries: 18911 |
30 |
Correct |
387 ms |
460 KB |
# of queries: 18932 |