#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int nax = 513;
vector<int>g[nax];
vector<int>order;
void dfs(int v, int p = 0) {
order.push_back(v);
for(int u : g[v]) if(u!=p) {
dfs(u, v);
}
}
int findEgg (int N, vector<pair<int,int>>bridges) {
for(int i=1; i<=N; ++i) {
g[i].clear();
}
order.clear();
for(int i=1; i<N; ++i) {
auto [u, v] = bridges[i-1];
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1);
int lo = 0, hi = N;
while(lo<hi-1) {
int mid = (lo+hi)/2;
vector<int>Qset;
for(int i=0; i<mid; ++i) {
Qset.push_back(order[i]);
}
if(query(Qset)) {
hi = mid;
} else {
lo = mid;
}
}
return order[lo];
}
# |
결과 |
실행 시간 |
메모리 |
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 |
10 ms |
352 KB |
Number of queries: 9 |
3 |
Correct |
16 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
336 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
380 KB |
Number of queries: 9 |
2 |
Correct |
11 ms |
368 KB |
Number of queries: 9 |
3 |
Correct |
16 ms |
348 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
356 KB |
Number of queries: 9 |