#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
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);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
328 KB |
Number of queries: 8 |
2 |
Correct |
16 ms |
340 KB |
Number of queries: 9 |
3 |
Correct |
24 ms |
340 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
456 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
368 KB |
Number of queries: 9 |
2 |
Correct |
23 ms |
340 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
348 KB |
Number of queries: 9 |
4 |
Correct |
24 ms |
328 KB |
Number of queries: 9 |