#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<ii> edges; //what we have found
vector<int> al[1005];
bool vis[1005];
vector<signed> ans;
void dfs(int i){
vis[i]=true;
ans.pub(i);
for (auto it:al[i]) if (!vis[it]) dfs(it);
}
int ask(int l,int r){
set<int> s;
rep(x,l,r+1) s.insert(x);
vector<signed> v(n,0);
for (auto it:s) v[it-1]=1;
int res=sz(s)-Query(v);
for (auto [a,b]:edges) if (s.count(a) && s.count(b)) res--;
return res;
}
void Solve(signed N){
n=N;
rep(x,1,n){
int lo=1,hi=n,mi;
while (hi-lo>1){
mi=hi+lo>>1;
if (ask(1,mi)) hi=mi;
else lo=mi;
}
int r=hi;
lo=1,hi=r,mi;
while (hi-lo>1){
mi=hi+lo>>1;
if (ask(mi,r)) lo=mi;
else hi=mi;
}
edges.pub({lo,r});
}
for (auto [a,b]:edges) al[a].pub(b),al[b].pub(a);
rep(x,1,n+1) if (sz(al[x])==1){
dfs(x);
break;
}
//for (auto it:ans) cout<<it<<" "; cout<<endl;
Answer(ans);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:55:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | mi=hi+lo>>1;
| ~~^~~
library.cpp:61:15: warning: right operand of comma operator has no effect [-Wunused-value]
61 | lo=1,hi=r,mi;
| ^
library.cpp:63:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
63 | mi=hi+lo>>1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
332 KB |
# of queries: 2796 |
2 |
Correct |
69 ms |
336 KB |
# of queries: 2780 |
3 |
Correct |
67 ms |
320 KB |
# of queries: 2926 |
4 |
Correct |
70 ms |
320 KB |
# of queries: 2926 |
5 |
Correct |
69 ms |
336 KB |
# of queries: 2932 |
6 |
Correct |
63 ms |
336 KB |
# of queries: 2929 |
7 |
Correct |
69 ms |
336 KB |
# of queries: 2922 |
8 |
Correct |
69 ms |
336 KB |
# of queries: 2770 |
9 |
Correct |
67 ms |
344 KB |
# of queries: 2919 |
10 |
Correct |
35 ms |
340 KB |
# of queries: 1717 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [4] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
332 KB |
# of queries: 2796 |
2 |
Correct |
69 ms |
336 KB |
# of queries: 2780 |
3 |
Correct |
67 ms |
320 KB |
# of queries: 2926 |
4 |
Correct |
70 ms |
320 KB |
# of queries: 2926 |
5 |
Correct |
69 ms |
336 KB |
# of queries: 2932 |
6 |
Correct |
63 ms |
336 KB |
# of queries: 2929 |
7 |
Correct |
69 ms |
336 KB |
# of queries: 2922 |
8 |
Correct |
69 ms |
336 KB |
# of queries: 2770 |
9 |
Correct |
67 ms |
344 KB |
# of queries: 2919 |
10 |
Correct |
35 ms |
340 KB |
# of queries: 1717 |
11 |
Incorrect |
0 ms |
208 KB |
Wrong Answer [4] |
12 |
Halted |
0 ms |
0 KB |
- |