#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
// #define int long long
#define lowbit(x) x&-x
const int maxn = 1005;
#include "library.h"
int n;
set<int> st;
int deg[maxn];
vector<int> adj[maxn];
int ed[maxn];
vector<pll> edge;
int con(vector<int> a){
set<int> cur;
for(auto x : a) cur.insert(x);
int cnt = 0;
for(auto [a, b] : edge) if(cur.count(a) && cur.count(b)) cnt++;
return cnt;
}
int qry(vector<int> a){
// cout<<"q : ";
// for(auto x : a) cout<<x<<" ";
// cout<<"\n";
// int op;
// cin>>op;
// cout<<"con : "<<con(a)<<"\n";
// return op < int(a.size()) - con(a);
vector<int> cur(n);
for(auto x : a) cur[x - 1] = 1;
int op = Query(cur);
return op < int(a.size()) - con(a);
}
void add(int a, int b){
adj[a].pb(b);
adj[b].pb(a);
deg[a] ++, deg[b] ++;
edge.eb(a, b);
if(deg[a] == 2) st.insert(a);
if(deg[b] == 2) st.insert(b);
if(deg[a] == 1 && deg[b] == 1) ed[a] = 1;
}
void Solve(int _n){
n = _n;
vector<int> q;
for(int rd = 0; rd < n - 1; rd++){
vector<int> cand;
for(int j = 1; j <= n; j++) cand.pb(j);
int l = 0, r = cand.size() - 1;
int ok = 0;
while(l + 1 < r){
// cout<<"bs : "<<l<<" "<<r<<"\n";
int m = (l + r) / 2;
vector<int> a, b;
for(int i = l; i <= m; i++) a.pb(cand[i]);
for(int i = m + 1; i <= r; i++) b.pb(cand[i]);
if(qry(a)) r = m, ok = 1;
else if(qry(b)) l = m + 1, ok = 1;
else break;
}
if(r == l + 1){
add(cand[l], cand[r]);
continue;
}
int m = (l + r) / 2;
int L = l, R = m;
while(L < R){
int mid = (L + R) / 2;
vector<int> a;
for(int i = m + 1; i <= r; i++) a.pb(cand[i]);
for(int i = L; i <= mid; i++) a.pb(cand[i]);
if(qry(a)) R = mid;
else L = mid + 1;
}
int fr = cand[L];
L = m + 1, R = r;
while(L < R){
int mid = (L + R) / 2;
vector<int> a;
a.pb(fr);
for(int i = L; i <= mid; i++) a.pb(cand[i]);
if(qry(a)) R = mid;
else L = mid + 1;
}
add(fr, cand[L]);
}
int pos;
for(int i = 1; i <= n; i++){
if(deg[i] == 1){
pos = i;
break;
}
}
vector<int> ans;
int prev = -1;
while(true){
ans.pb(pos);
int ok = 0;
for(auto x : adj[pos]){
if(x != prev){
prev = pos, pos = x, ok = 1;
break;
}
}
if(!ok) break;
}
// cout<<"ans : ";
// for(auto x : ans) cout<<x<<" ";
// cout<<"\n";
Answer(ans);
}
signed main(void){
int n;
cin>>n;
Solve(n);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:59:7: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
59 | int ok = 0;
| ^~
/usr/bin/ld: /tmp/ccr0ciIN.o: in function `main':
library.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccuJjYaM.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status