#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define fi first
#define se second
#define ll long long
vector< vector<int> > g;
vector<int> thutu;
void dfs(int u, int t)
{
thutu.push_back(u);
for(int i = 0; i < int(g[u].size()); ++i)
{
int v = g[u][i];
if(v == t) continue;
dfs(v, u);
}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
g.clear();
thutu.clear();
g.resize(n+1);
for(int i = 0; i < int(bridges.size()); ++i)
{
g[bridges[i].fi].push_back(bridges[i].se);
g[bridges[i].se].push_back(bridges[i].fi);
}
dfs(1, 0);
int l = 0; int r = n-1;
while(l < r)
{
int mid = (l+r+1)/2;
if(query(vector<int>(thutu.begin(), thutu.begin()+mid)))
r = mid-1;
else l = mid;
}
return thutu[l];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
336 KB |
Number of queries: 8 |
2 |
Correct |
13 ms |
348 KB |
Number of queries: 9 |
3 |
Correct |
15 ms |
352 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
336 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
356 KB |
Number of queries: 9 |
2 |
Correct |
19 ms |
348 KB |
Number of queries: 9 |
3 |
Correct |
15 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
15 ms |
340 KB |
Number of queries: 9 |