#include <bits/stdc++.h>
#include "grader.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define pii pair<int, int>
using namespace std;
const int NN = 513;
vector<int> edges[NN];
vector<int> vv;
int nn;
void dfs(int u, int p = -1){
vv.pb(u);
for(auto x:edges[u]){
if(x == p) continue;
dfs(x, u);
}
}
int findEgg (int N, vector < pair < int, int > > bb){
for(int i=0;i<NN;i++) edges[i].clear();
for(auto x:bb){
edges[x.ff].pb(x.ss);
edges[x.ss].pb(x.ff);
}
vv.clear();
dfs(1);
int l = 0, r = sz(vv)-1;
while(l < r){
int m = (l + r)>>1;
vector<int> tt;
for(int i=0;i<=m;i++) tt.pb(vv[i]);
if(query(tt)) r = m;
else l = m+1;
}
return vv[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
364 KB |
Number of queries: 8 |
2 |
Correct |
17 ms |
364 KB |
Number of queries: 9 |
3 |
Correct |
23 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
492 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
364 KB |
Number of queries: 9 |
2 |
Correct |
19 ms |
364 KB |
Number of queries: 9 |
3 |
Correct |
22 ms |
440 KB |
Number of queries: 9 |
4 |
Correct |
23 ms |
620 KB |
Number of queries: 9 |