This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
#define ll long long
//#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define pb push_back
#define pii pair<int,int>
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << " " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", ";_do(y...);}
#else
#define bug(...) 49
#endif
const int maxn=605;
int cur;
bool alive[maxn],pick[maxn];
vector<int> adj[maxn],vec;
void dfs(int u, int tar){
if(cur==tar) return;
pick[u]=1;
vec.pb(u+1);
if(alive[u]) cur++;
for(auto v: adj[u]) if(!pick[v]) dfs(v,tar);
}
int findEgg(int n, vector<pii> edges){
rep(n) alive[i]=1,adj[i].clear();
for(auto& [x,y]: edges) x--,y--;
for(auto& [x,y]: edges) adj[x].pb(y),adj[y].pb(x);
while(1){
int x=0;
rep(n) if(alive[i]) x++;
bug(x);
if(x==1){
rep(n) if(alive[i]) return i+1;
}
vec.clear();
memset(pick,0,sizeof pick);
cur=0;
dfs(0,x/2);
int res=query(vec);
for(auto i: vec) bug(i);
rep(n) bug(i,pick[i]);
bug(res);
bug(alive[0]);
if(res) rep(n) if(alive[i]&&!pick[i]) alive[i]=0,bug(i);
if(!res) rep(n) if(alive[i]&&pick[i]) alive[i]=0;
}
}
Compilation message (stderr)
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
22 | #define bug(...) 49
| ^~
eastereggs.cpp:46:9: note: in expansion of macro 'bug'
46 | bug(x);
| ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
22 | #define bug(...) 49
| ^~
eastereggs.cpp:55:26: note: in expansion of macro 'bug'
55 | for(auto i: vec) bug(i);
| ^~~
eastereggs.cpp:55:18: warning: unused variable 'i' [-Wunused-variable]
55 | for(auto i: vec) bug(i);
| ^
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
22 | #define bug(...) 49
| ^~
eastereggs.cpp:56:16: note: in expansion of macro 'bug'
56 | rep(n) bug(i,pick[i]);
| ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
22 | #define bug(...) 49
| ^~
eastereggs.cpp:57:9: note: in expansion of macro 'bug'
57 | bug(res);
| ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
22 | #define bug(...) 49
| ^~
eastereggs.cpp:58:9: note: in expansion of macro 'bug'
58 | bug(alive[0]);
| ^~~
eastereggs.cpp:59:64: warning: right operand of comma operator has no effect [-Wunused-value]
59 | if(res) rep(n) if(alive[i]&&!pick[i]) alive[i]=0,bug(i);
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |