#include<iostream>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int N = 10000;
vector<int> g[N];
vector<int> ord;
void dfs(int s, int p) {
ord.push_back(s);
for(int to : g[s])
if(to != p)
dfs(to, s);
}
void Solve(int n) {
vector<pair<int, int>> edges;
for(int iter = 1; iter < n; iter++) {
int a, b;
int lb = 0, rb = n + 1;
while(rb - lb > 1) {
int mid = (lb + rb) / 2;
vector<int> q(n);
for(int i = 1; i <= mid; i++)
q[i - 1] = 1;
int cmp = mid;
for(auto [l, r] : edges) {
cmp -= (1 <= l && r <= mid);
}
if(Query(q) < cmp) rb = mid;
else lb = mid;
}
b = rb;
lb = 0, rb = b;
while(rb - lb > 1) {
int mid = (lb + rb) / 2;
vector<int> q(n);
for(int i = mid; i <= b; i++)
q[i - 1] = 1;
int cmp = b - mid + 1;
for(auto [l, r] : edges)
cmp -= (mid <= l && r <= b);
if(Query(q) < cmp) lb = mid;
else rb = mid;
}
a = lb;
edges.push_back({a, b});
}
for(auto [u, v] : edges) {
g[u].push_back(v);
g[v].push_back(u);
}
int t = 0;
for(int i = 1; i <= n; i++)
if((int)g[i].size() <= 1) t = i;
dfs(t, t);
Answer(ord);
// for(auto [u, v] : edges) cout << '(' << u << ' ' << v << ')' << ' ';
// cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
464 KB |
# of queries: 2797 |
2 |
Correct |
29 ms |
536 KB |
# of queries: 2784 |
3 |
Correct |
28 ms |
464 KB |
# of queries: 2931 |
4 |
Correct |
33 ms |
464 KB |
# of queries: 2935 |
5 |
Correct |
31 ms |
464 KB |
# of queries: 2936 |
6 |
Correct |
31 ms |
528 KB |
# of queries: 2938 |
7 |
Correct |
24 ms |
524 KB |
# of queries: 2924 |
8 |
Correct |
33 ms |
464 KB |
# of queries: 2791 |
9 |
Correct |
27 ms |
536 KB |
# of queries: 2926 |
10 |
Correct |
20 ms |
464 KB |
# of queries: 1719 |
11 |
Correct |
0 ms |
464 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
512 KB |
# of queries: 3 |
13 |
Correct |
0 ms |
464 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
464 KB |
# of queries: 13 |
15 |
Correct |
1 ms |
464 KB |
# of queries: 103 |
16 |
Correct |
2 ms |
464 KB |
# of queries: 238 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
464 KB |
# of queries: 2797 |
2 |
Correct |
29 ms |
536 KB |
# of queries: 2784 |
3 |
Correct |
28 ms |
464 KB |
# of queries: 2931 |
4 |
Correct |
33 ms |
464 KB |
# of queries: 2935 |
5 |
Correct |
31 ms |
464 KB |
# of queries: 2936 |
6 |
Correct |
31 ms |
528 KB |
# of queries: 2938 |
7 |
Correct |
24 ms |
524 KB |
# of queries: 2924 |
8 |
Correct |
33 ms |
464 KB |
# of queries: 2791 |
9 |
Correct |
27 ms |
536 KB |
# of queries: 2926 |
10 |
Correct |
20 ms |
464 KB |
# of queries: 1719 |
11 |
Correct |
0 ms |
464 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
512 KB |
# of queries: 3 |
13 |
Correct |
0 ms |
464 KB |
# of queries: 7 |
14 |
Correct |
1 ms |
464 KB |
# of queries: 13 |
15 |
Correct |
1 ms |
464 KB |
# of queries: 103 |
16 |
Correct |
2 ms |
464 KB |
# of queries: 238 |
17 |
Correct |
246 ms |
652 KB |
# of queries: 19266 |
18 |
Correct |
235 ms |
540 KB |
# of queries: 19022 |
19 |
Correct |
222 ms |
532 KB |
# of queries: 19225 |
20 |
Correct |
234 ms |
532 KB |
# of queries: 18016 |
21 |
Correct |
180 ms |
536 KB |
# of queries: 16925 |
22 |
Correct |
228 ms |
540 KB |
# of queries: 19268 |
23 |
Correct |
237 ms |
532 KB |
# of queries: 19242 |
24 |
Correct |
89 ms |
524 KB |
# of queries: 8893 |
25 |
Correct |
248 ms |
660 KB |
# of queries: 18813 |
26 |
Correct |
182 ms |
536 KB |
# of queries: 17601 |
27 |
Correct |
110 ms |
528 KB |
# of queries: 8861 |
28 |
Correct |
279 ms |
536 KB |
# of queries: 18945 |
29 |
Correct |
226 ms |
536 KB |
# of queries: 18924 |
30 |
Correct |
174 ms |
656 KB |
# of queries: 18945 |