#include <bits/stdc++.h>
#include "library.h"
#include "grader.cpp"
using namespace std;
bool E[1000][1000],VIS[1000];
int CNT[1000],NN;
void DFS(int v,int L,int R,int BL){
if(VIS[v])return;
VIS[v] = 1;
for(int i = 0; i < NN; i += 1)if(E[i][v] && i >= L && i <= R && i != BL)DFS(i,L,R,BL);
}
int BS(int idx,int BL = -1){
int L = 0, R = idx - 1 -(BL != -1), mid;
while(L <= R){
if(L == R){
E[idx][L + (L >= BL && BL != -1)] = E[L + (L >= BL && BL != -1)][idx] = 1;
CNT[idx]++,CNT[L + (L >= BL && BL != -1)]++;
//cout<<L + 1 + (L >= BL && BL != -1)<<endl;
return L + (L >= BL && BL != -1);
}
//cout<<L<<' '<<R<<endl;
vector<int>F(NN,0);
mid = (L + R) / 2;
int Z = 0;
for(int i = L; i <= mid; i += 1)F[i + (BL != -1 && i >= BL)] = 1;
F[idx] = 1;
for(int i = L; i <= mid; i += 1){
//cout<<"Q: " <<i + (BL != -1 && i >= BL)<<endl;
if(!VIS[i + (BL != -1 && i >= BL)])DFS(i + (BL != -1 && i >= BL),L,mid + (BL != -1 && mid >= BL),BL),Z++;
}
//cout<<"Z: "<<Z<<' '<<Query(F)<<endl;
if(Z >= Query(F))R = mid;
else L = mid + 1;
for(int i = 0; i < NN; i += 1)VIS[i] = 0;
}
}
void Solve(int N)
{
NN = N;
vector<int> M(N);
M[0] = 1;
int LST = 1;
for(int i = 1; i < N; i += 1){
M[i] = 1;
int A = Query(M);
if(A <= LST){
//cout<<"Hmm: "<<i + 1<<endl;
if(A == LST)BS(i);
else{
int Q = BS(i);
//cout<<"BL: "<<Q<<endl;
BS(i,Q);
}
}
LST = A;
}
int S = 0, P = -1;
for(int i = 0; i < N; i += 1)if(CNT[i] == 1){S = i;}
vector<int> res;
while(1){
res.push_back(S + 1);
//cout<<S + 1<<' ';
for(int i = 0; i < N; i += 1)if(i != P && E[S][i]){P = S, S = i; goto a;}
break;
a:;
}
//cout<<res.size()<<endl;
Answer(res);
}
Compilation message
library.cpp: In function 'int BS(int, int)':
library.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
36 | }
| ^
/usr/bin/ld: /tmp/ccMS2Qw3.o: in function `Query(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0xb0): multiple definition of `Query(std::vector<int, std::allocator<int> > const&)'; /tmp/ccITQbXZ.o:grader.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccMS2Qw3.o:(.bss+0xf5600): multiple definition of `__my_judge_::judge'; /tmp/ccITQbXZ.o:(.bss+0x0): first defined here
/usr/bin/ld: /tmp/ccMS2Qw3.o: in function `Answer(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0xd0): multiple definition of `Answer(std::vector<int, std::allocator<int> > const&)'; /tmp/ccITQbXZ.o:grader.cpp:(.text+0x20): first defined here
/usr/bin/ld: /tmp/ccMS2Qw3.o: in function `main':
library.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccITQbXZ.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status