#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int MAXN = 520;
vector<int> adj[MAXN], v;
void dfs(int s, int p){
v.push_back(s);
for(int viz : adj[s])
if(viz != p)dfs(viz,s);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(int i = 1; i <= n; i++)adj[i].clear();
v.clear();
for(int i = 0; i < n-1; i++){
adj[bridges[i].first].push_back(bridges[i].second);
adj[bridges[i].second].push_back(bridges[i].first);
}
dfs(1,0);
int l = 0, r = n-1;
while(l != r){
int mid = (l+r)/2;
vector<int> temp;
for(int i = 0; i <= mid; i++)temp.push_back(v[i]);
if(query(temp) == 1)r = mid;
else l = mid+1;
}
return v[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
336 KB |
Number of queries: 4 |
3 |
Correct |
2 ms |
336 KB |
Number of queries: 4 |
4 |
Correct |
2 ms |
336 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
592 KB |
Number of queries: 8 |
2 |
Correct |
14 ms |
500 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
584 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
336 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
672 KB |
Number of queries: 9 |
2 |
Correct |
14 ms |
500 KB |
Number of queries: 9 |
3 |
Correct |
18 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
592 KB |
Number of queries: 9 |