#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "library.h"
const int N=2222;
int n,a[N];
vector<int> res,g[N];
vector<pair<int,int> > ans;
void dfs(int u,int p){
res.pb(u+1);
for(auto v : g[u]){
if(v==p) continue ;
dfs(v,u);
}
}
int ask(int l,int r){
vector<int> M(n);
f(i,l,r+1) M[i]=1;
int res=r-l+1-Query(M);
for(auto p : ans){
if(l<=p.F && p.F<=r && l<=p.S && p.S<=r){
res--;
}
}
return res;
}
void Solve(int _n){
n=_n;
f_(i,n-1,0){
int t=ask(i,n-1);
while(t--){
int l=i,r=n-1;
while(l+1<r){
int mid=(l+r)/2;
if(ask(i,mid)){
r=mid;
}
else{
l=mid;
}
}
int u=i,v=r;
g[u].pb(v);
g[v].pb(u);
ans.pb({u,v});
}
}
f(i,0,n){
if(g[i].size()==1 || i==n-1){
dfs(i,i);
Answer(res);
return ;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
328 KB |
# of queries: 1525 |
2 |
Correct |
21 ms |
448 KB |
# of queries: 1501 |
3 |
Correct |
25 ms |
352 KB |
# of queries: 1596 |
4 |
Correct |
20 ms |
340 KB |
# of queries: 1590 |
5 |
Correct |
26 ms |
328 KB |
# of queries: 1590 |
6 |
Correct |
24 ms |
352 KB |
# of queries: 1575 |
7 |
Correct |
28 ms |
336 KB |
# of queries: 1590 |
8 |
Correct |
23 ms |
348 KB |
# of queries: 1518 |
9 |
Correct |
25 ms |
336 KB |
# of queries: 1598 |
10 |
Correct |
12 ms |
352 KB |
# of queries: 940 |
11 |
Correct |
0 ms |
328 KB |
# of queries: 1 |
12 |
Correct |
0 ms |
328 KB |
# of queries: 2 |
13 |
Correct |
0 ms |
328 KB |
# of queries: 5 |
14 |
Correct |
0 ms |
328 KB |
# of queries: 8 |
15 |
Correct |
1 ms |
328 KB |
# of queries: 59 |
16 |
Correct |
2 ms |
328 KB |
# of queries: 133 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
328 KB |
# of queries: 1525 |
2 |
Correct |
21 ms |
448 KB |
# of queries: 1501 |
3 |
Correct |
25 ms |
352 KB |
# of queries: 1596 |
4 |
Correct |
20 ms |
340 KB |
# of queries: 1590 |
5 |
Correct |
26 ms |
328 KB |
# of queries: 1590 |
6 |
Correct |
24 ms |
352 KB |
# of queries: 1575 |
7 |
Correct |
28 ms |
336 KB |
# of queries: 1590 |
8 |
Correct |
23 ms |
348 KB |
# of queries: 1518 |
9 |
Correct |
25 ms |
336 KB |
# of queries: 1598 |
10 |
Correct |
12 ms |
352 KB |
# of queries: 940 |
11 |
Correct |
0 ms |
328 KB |
# of queries: 1 |
12 |
Correct |
0 ms |
328 KB |
# of queries: 2 |
13 |
Correct |
0 ms |
328 KB |
# of queries: 5 |
14 |
Correct |
0 ms |
328 KB |
# of queries: 8 |
15 |
Correct |
1 ms |
328 KB |
# of queries: 59 |
16 |
Correct |
2 ms |
328 KB |
# of queries: 133 |
17 |
Correct |
261 ms |
496 KB |
# of queries: 10259 |
18 |
Correct |
268 ms |
336 KB |
# of queries: 10166 |
19 |
Correct |
270 ms |
468 KB |
# of queries: 10277 |
20 |
Correct |
255 ms |
476 KB |
# of queries: 9614 |
21 |
Correct |
218 ms |
360 KB |
# of queries: 9058 |
22 |
Correct |
262 ms |
468 KB |
# of queries: 10296 |
23 |
Correct |
282 ms |
372 KB |
# of queries: 10276 |
24 |
Correct |
88 ms |
328 KB |
# of queries: 4773 |
25 |
Correct |
262 ms |
368 KB |
# of queries: 10061 |
26 |
Correct |
232 ms |
364 KB |
# of queries: 9404 |
27 |
Correct |
82 ms |
344 KB |
# of queries: 4758 |
28 |
Correct |
221 ms |
372 KB |
# of queries: 8978 |
29 |
Correct |
211 ms |
464 KB |
# of queries: 8968 |
30 |
Correct |
214 ms |
368 KB |
# of queries: 8978 |