#include <bits/stdc++.h>
#include "library.h"
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
int n;
vector<pair<int,int>> ed;
vector<int> ans, adj[1500];
void dfs(int s, int p){
ans.pb(s);
for(auto u : adj[s])
if(u!=p) dfs(u,s);
}
int chk(int l, int r, int q){
int ans = 0;
for(auto [a,b] : ed) ans+=a>=l and b<=r;
return r-l+1-q-ans>0;
}
void Solve(int N)
{
n = N; int tot = 0;
vector<int> M(N,0);
while(tot<n-1){
int l = 1, r = n;
while(l<r){
int mid = (l+r)/2;
fill(begin(M),begin(M)+mid,1);
if(chk(1,mid,Query(M))) r=mid;
else l=mid+1;
fill(begin(M),begin(M)+mid,0);
}
int i = l;
l = 1, r = i;
while(l<r){
int mid = (l+r+1)/2;
fill(begin(M)+mid-1,begin(M)+i,1);
if(chk(mid,i,Query(M))) l=mid;
else r=mid-1;
fill(begin(M)+mid-1,begin(M)+i,0);
}
adj[i].pb(l), adj[l].pb(i), ed.pb({l,i}); tot++;
}
for(int i = 1; i <= N; i++){
if(sz(adj[i])==1){
dfs(i,-1), Answer(ans);
return;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
336 KB |
# of queries: 2790 |
2 |
Correct |
32 ms |
336 KB |
# of queries: 2779 |
3 |
Correct |
35 ms |
328 KB |
# of queries: 2933 |
4 |
Correct |
35 ms |
380 KB |
# of queries: 2926 |
5 |
Correct |
36 ms |
336 KB |
# of queries: 2933 |
6 |
Correct |
22 ms |
328 KB |
# of queries: 2924 |
7 |
Correct |
29 ms |
336 KB |
# of queries: 2915 |
8 |
Correct |
30 ms |
340 KB |
# of queries: 2791 |
9 |
Correct |
33 ms |
340 KB |
# of queries: 2922 |
10 |
Correct |
19 ms |
336 KB |
# of queries: 1714 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [7] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
336 KB |
# of queries: 2790 |
2 |
Correct |
32 ms |
336 KB |
# of queries: 2779 |
3 |
Correct |
35 ms |
328 KB |
# of queries: 2933 |
4 |
Correct |
35 ms |
380 KB |
# of queries: 2926 |
5 |
Correct |
36 ms |
336 KB |
# of queries: 2933 |
6 |
Correct |
22 ms |
328 KB |
# of queries: 2924 |
7 |
Correct |
29 ms |
336 KB |
# of queries: 2915 |
8 |
Correct |
30 ms |
340 KB |
# of queries: 2791 |
9 |
Correct |
33 ms |
340 KB |
# of queries: 2922 |
10 |
Correct |
19 ms |
336 KB |
# of queries: 1714 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [7] |
12 |
Halted |
0 ms |
0 KB |
- |