#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 512;
vector<int> adj[N];
vector<int> order;
void dfs(int node, int p = -1){
order.emplace_back(node);
for (int i:adj[node]){
if (i != p){
dfs(i,node);
}
}
}
int findEgg (int N, vector < pair < int, int > > bridges){
for (int i=0; i<N; ++i){
adj[i].clear();
}
order.clear();
for (auto [a,b]:bridges){
a--; b--;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
dfs(0);
int deb = 0, fin = N-1;
while (deb < fin){
int mid = (deb+fin)/2;
vector<int> q;
for (int i=0; i<=mid; ++i){
q.emplace_back(order[i]+1);
}
if (query(q)){
fin = mid;
}
else{
deb = mid+1;
}
}
return order[deb]+1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
480 KB |
Number of queries: 8 |
2 |
Correct |
9 ms |
744 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
496 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
740 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
608 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
732 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
744 KB |
Number of queries: 9 |
4 |
Correct |
12 ms |
752 KB |
Number of queries: 9 |