#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 |
18 ms |
540 KB |
# of queries: 2797 |
2 |
Correct |
30 ms |
520 KB |
# of queries: 2784 |
3 |
Correct |
36 ms |
464 KB |
# of queries: 2931 |
4 |
Correct |
37 ms |
524 KB |
# of queries: 2935 |
5 |
Correct |
34 ms |
540 KB |
# of queries: 2936 |
6 |
Correct |
29 ms |
520 KB |
# of queries: 2938 |
7 |
Correct |
29 ms |
540 KB |
# of queries: 2924 |
8 |
Correct |
26 ms |
536 KB |
# of queries: 2791 |
9 |
Correct |
31 ms |
540 KB |
# of queries: 2926 |
10 |
Correct |
15 ms |
464 KB |
# of queries: 1719 |
11 |
Incorrect |
0 ms |
464 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
540 KB |
# of queries: 2797 |
2 |
Correct |
30 ms |
520 KB |
# of queries: 2784 |
3 |
Correct |
36 ms |
464 KB |
# of queries: 2931 |
4 |
Correct |
37 ms |
524 KB |
# of queries: 2935 |
5 |
Correct |
34 ms |
540 KB |
# of queries: 2936 |
6 |
Correct |
29 ms |
520 KB |
# of queries: 2938 |
7 |
Correct |
29 ms |
540 KB |
# of queries: 2924 |
8 |
Correct |
26 ms |
536 KB |
# of queries: 2791 |
9 |
Correct |
31 ms |
540 KB |
# of queries: 2926 |
10 |
Correct |
15 ms |
464 KB |
# of queries: 1719 |
11 |
Incorrect |
0 ms |
464 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |