#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,int>pi2;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
bool take[1005];
bool visited[1005];
int cnt=0;
int need=0;
vector<int>vv;
vector<int>adj[1005];
void dfs(int index){
if(cnt==need) return;
visited[index]=true;
vv.push_back(index);
if(!take[index]) cnt++;
if(cnt==need) return;
for(auto it:adj[index]){
if(visited[it]) continue;
dfs(it);
}
}
int findEgg(int n, vector<pair<int,int>>bridges){
memset(take,0,sizeof(take));
for(int x=1;x<=n;x++) adj[x].clear();
for(auto it:bridges){
adj[it.first].push_back(it.second);
adj[it.second].push_back(it.first);
}
int cur=n;
while(cur>1){
need=cur/2;
memset(visited,0,sizeof(visited));
cnt=0;
vv.clear();
dfs(1);
bool hold=query(vv);
if(hold){
for(int y=1;y<=n;y++){
if(!visited[y]) take[y]=true;
}
cur=need;
}
else{
for(int y=1;y<=n;y++){
if(visited[y]) take[y]=true;
}
cur=cur-need;
}
}
for(int x=1;x<=n;x++){
if(!take[x]) return x;
}
}
컴파일 시 표준 에러 (stderr) 메시지
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
69 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |