/*
We found Despacito 5 during contest (not clickbait)
*/
#include <vector>
#include <set>
#include <cassert>
using namespace std;
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define cl(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ll long long
#define ld long double
#define vec vector
#define vi vec<int>
#define heap priority_queue
#define res reserve
#define pb push_back
#define f(x,y,z) for(int x=(y); x<(z); x++)
#define fd(x,y,z) for(int x=(y); x>=(z); x--)
#define fit(x,y) for(auto x: y)
#define srt(x) sort(all(x))
#define rsrt(x) sort(rall(x))
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define pii pair<int,ll>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define mp make_pair
#define f1 first
#define s2 second
#define cdbg(x) cerr<<#x<<" = "<<x<<",\t";
#define cdbl cerr<<"\n----------\n";
#define pow2(x) ((x)*(x))
#define edist(x1, y1, x2, y2) (sqrt((pow2(x1-x2)+pow2(y1-y2))))
#define mdist(x1, y1, x2, y2) (abs((x1)-(x2))+abs((y1)-(y2)))
#define y1 FullSensei
#define mid ((ss+se)>>1)
#define left (si<<1)
#define right ((si<<1)+1)
#define pi 3.141592653589793
#define popcount __builtin_popcount
#define spc ' '
#define endl '\n'
#define lb lower_bound
bool checkbit(int x,int y){return (x&(1<<y));}
int setbit(int x,int y){return (x^(1<<y));}
const int dirs[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int mod=1e9+7;
const int p1=805306457;
const int p2=1610612741;
const int INF=1e9;
int n;
vi e[16+7];
bool possible[16+7];
vi chosen;
int chosenCnt;
bool chosens[16+7];
int rem;
void dfs(int root, int parent){
chosen.pb(root);
if(possible[root])
chosenCnt++;
chosens[root]=1;
if(abs(rem-chosenCnt)<=1){
return;
}
fit(child,e[root]){
if(child==parent) continue;
dfs(child,root);
if(abs(rem-chosenCnt)<=1){
return;
}
}
}
int findEgg(int N, vector<pii>bridges){
n=N;
assert(n<=16);
fit(x,bridges){
e[x.f1].pb(x.s2);
e[x.s2].pb(x.f1);
}
rem=n;
while(rem>1){
chosen.clear();
cl(chosens,0);
chosenCnt=0;
for(int i=1; i<=n; i++){
if(possible[i]){
dfs(i,0);
break;
}
}
if(query(chosen)){
rem=chosenCnt;
for(int i=1; i<=n; i++)
if(possible[i] && chosens[i]==0)
possible[i]=0;
}
else{
rem-=chosen.size();
for(int i=0; i<chosen.size(); i++)
possible[chosen[i]]=0;
}
}
for(int i=1; i<=n; i++)
if(possible[i])
return i;
}
Compilation message
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:68:5: error: 'abs' was not declared in this scope
if(abs(rem-chosenCnt)<=1){
^~~
eastereggs.cpp:74:6: error: 'abs' was not declared in this scope
if(abs(rem-chosenCnt)<=1){
^~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, long long int> >)':
eastereggs.cpp:11:21: error: 'memset' was not declared in this scope
#define cl(a,b) memset(a,b,sizeof(a))
^
eastereggs.cpp:90:3: note: in expansion of macro 'cl'
cl(chosens,0);
^~
eastereggs.cpp:11:21: note: suggested alternative: 'mdist'
#define cl(a,b) memset(a,b,sizeof(a))
^
eastereggs.cpp:90:3: note: in expansion of macro 'cl'
cl(chosens,0);
^~
eastereggs.cpp:98:6: error: 'query' was not declared in this scope
if(query(chosen)){
^~~~~
eastereggs.cpp:106:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<chosen.size(); i++)
~^~~~~~~~~~~~~~
eastereggs.cpp:113:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^