#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int>dfsorder;
vector<int>g[600];
void dfs(int source,int p)
{
dfsorder.push_back(source);
for(int go:g[source])
if(go!=p)dfs(go,source);
}
int findEgg (int N,vector<pair<int,int> >bridges)
{
for(int i=1;i<=N;i++) g[i].clear();
for(int i=0;i<N-1;i++)
{
g[bridges[i].first].push_back(bridges[i].second);
g[bridges[i].second].push_back(bridges[i].first);
}
dfs(1,0);
int l=0,r=N-2;
int mid;
while(l<=r)
{
mid=(l+r)/2;
if(query(vector<int>(dfsorder.begin(),dfsorder.begin()+mid+1)))
r=mid-1;
else l=mid+1;
}
return dfsorder[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
612 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
448 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
456 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
452 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
736 KB |
Number of queries: 8 |
2 |
Correct |
7 ms |
988 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
1524 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
1496 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
1320 KB |
Number of queries: 9 |
2 |
Correct |
9 ms |
1244 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
1424 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
1780 KB |
Number of queries: 9 |