#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
vector<int>g[605];
void dfs(int node, int par)
{
v.push_back(node);
for(int i : g[node])
{
if(i != par)
dfs(i,node);
}
}
int findEgg (int n, vector<pair<int,int>>b)
{
v.clear();
for(int i = 0; i <= n; ++i)
g[i].clear();
for(pair<int,int> i : b)
{
g[i.first].push_back(i.second);
g[i.second].push_back(i.first);
}
dfs(1,1);
int l = 0, r = v.size() - 1;
while(l < r)
{
int mid = (l + r) / 2;
vector<int>w;
for(int i = 0; i <= mid; ++i)
w.push_back(v[i]);
if(query(w))
r = mid;
else
l = mid + 1;
}
return v[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
476 KB |
Number of queries: 8 |
2 |
Correct |
7 ms |
732 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
752 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
748 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
516 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
1248 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
1240 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
748 KB |
Number of queries: 9 |