#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<vector<int>> adj;
vector<int> ordre;
void dfs(int actual, int anterior){
ordre.push_back(actual);
for (auto v : adj[actual]){
if (v != anterior){
dfs(v, actual);
}
}
}
int findEgg (int N, vector<pair<int, int>> bridges){
adj = vector<vector<int>>(N+1);
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 r = N, l = 1;
while (r >= l){
int m = (r+l)/2;
if (query(vector<int>(ordre.begin(), ordre.begin()+m))){
r = m-1;
}
else{
l = m+1;
}
}
return ordre[r];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
336 KB |
Number of queries: 9 |
2 |
Correct |
15 ms |
400 KB |
Number of queries: 9 |
3 |
Correct |
16 ms |
440 KB |
Number of queries: 9 |
4 |
Correct |
19 ms |
584 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
16 ms |
584 KB |
Number of queries: 10 |
2 |
Correct |
14 ms |
536 KB |
Number of queries: 9 |
3 |
Partially correct |
16 ms |
540 KB |
Number of queries: 10 |
4 |
Partially correct |
14 ms |
464 KB |
Number of queries: 10 |