#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "Yes" << en
#define no cout << "No" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))
using namespace std;
const ll LINF = 1e18;
const int mxN = 1e3+10, INF = 2e9;
ll n;
vector<int> g[mxN], ans;
void dfs(int s, int p = -1){
ans.pb(s+1);
for (int u : g[s])
if (u^p) dfs(u, s);
}
int Get(int i, int l, int r){
vector<int> M(n, 0);
for (int i = l; i <= r; i++)
M[i] = 1;
int x = Query(M);
M[i] = 1;
return 1 - (Query(M) - x);
}
void BS(int i, int l, int r, int x){
if (l == r){
g[i].pb(l);
g[l].pb(i);
return;
}
int k = (l + r)>>1;
int y = Get(i, l, k);
if (y) BS(i, l, k, y);
if (x-y) BS(i, k+1, r, x-y);
}
void Solve(int N)
{
n = N;
for (int i = 1; i < n; i++){
int x = Get(i, 0, i-1);
if (x) BS(i, 0, i-1, x);
}
int s;
for (s = 0; s < n; s++)
if (g[s].size() == 1)
break;
dfs(s);
Answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
312 KB |
# of queries: 2730 |
2 |
Correct |
47 ms |
324 KB |
# of queries: 2798 |
3 |
Correct |
37 ms |
208 KB |
# of queries: 2864 |
4 |
Correct |
39 ms |
208 KB |
# of queries: 2898 |
5 |
Correct |
40 ms |
436 KB |
# of queries: 2884 |
6 |
Correct |
40 ms |
324 KB |
# of queries: 2850 |
7 |
Correct |
47 ms |
308 KB |
# of queries: 2940 |
8 |
Correct |
40 ms |
324 KB |
# of queries: 2796 |
9 |
Correct |
42 ms |
324 KB |
# of queries: 2930 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1712 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
312 KB |
# of queries: 2730 |
2 |
Correct |
47 ms |
324 KB |
# of queries: 2798 |
3 |
Correct |
37 ms |
208 KB |
# of queries: 2864 |
4 |
Correct |
39 ms |
208 KB |
# of queries: 2898 |
5 |
Correct |
40 ms |
436 KB |
# of queries: 2884 |
6 |
Correct |
40 ms |
324 KB |
# of queries: 2850 |
7 |
Correct |
47 ms |
308 KB |
# of queries: 2940 |
8 |
Correct |
40 ms |
324 KB |
# of queries: 2796 |
9 |
Correct |
42 ms |
324 KB |
# of queries: 2930 |
10 |
Correct |
20 ms |
208 KB |
# of queries: 1712 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [5] |
12 |
Halted |
0 ms |
0 KB |
- |