#include<bits/stdc++.h>
#include "grader.h"
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000000000000
#define MOD 1000000007
#define MAX 555
#define LOG 22
using namespace std;
int cursz,now,mark[MAX];
vector<int> send;
bool init;
vector<int> v[MAX];
void find_path(int node,int ata) {
if(now==cursz/2) return ;
send.pb(node);
now+=!mark[node];
for(int i:v[node]) {
if(i==ata) continue ;
find_path(i,node);
}
}
int findEgg (int N, vector < pair < int, int > > bridges) {
for(int i=1;i<=N;i++) mark[i]=0;
if(!init) {
for(int i=0;i<N-1;i++) {
v[bridges[i].st].pb(bridges[i].nd);
v[bridges[i].nd].pb(bridges[i].st);
}
init=true;
}
cursz=N;
while(cursz>1) {
now=0;
find_path(1,0);
if(!query(send)) {
for(int i:send) mark[i]=1;
cursz-=cursz/2;
}
else {
cursz=cursz/2;
for(int i=1;i<=N;i++) mark[i]=1;
for(int i:send) mark[i]=0;
}
send.clear();
}
for(int i=1;i<=N;i++) if(!mark[i]) return i;
}
Compilation message
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:96:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
628 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |