#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]++;
for(int i:send) mark[i]--;
}
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 |
Correct |
2 ms |
248 KB |
Number of queries: 4 |
2 |
Correct |
3 ms |
308 KB |
Number of queries: 4 |
3 |
Correct |
3 ms |
512 KB |
Number of queries: 4 |
4 |
Correct |
3 ms |
512 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
528 KB |
Number of queries: 8 |
2 |
Correct |
20 ms |
528 KB |
Number of queries: 9 |
3 |
Correct |
35 ms |
568 KB |
Number of queries: 9 |
4 |
Correct |
29 ms |
568 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
568 KB |
Number of queries: 9 |
2 |
Correct |
22 ms |
572 KB |
Number of queries: 9 |
3 |
Correct |
28 ms |
572 KB |
Number of queries: 9 |
4 |
Correct |
27 ms |
572 KB |
Number of queries: 9 |