#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int n = 1000;
vector<int> g[n];
vector<int> v;
void dfs(int at, int p) {
v.push_back(at);
for(int to:g[at]) {
if(to==p)continue;
dfs(to, at);
}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
for(auto i:bridges) {
g[i.first].push_back(i.second);
g[i.second].push_back(i.first);
}
dfs(1,0);
int l = 0, r = v.size()-1, res = -1;
while(l <= r) {
int mid = (l+r)/2;
vector<int> q;
for(int i = 0;i<=mid;i++)q.push_back(v[i]);
if(query(q)) {
r=mid-1;
res=v[mid];
}
else {
l=mid+1;
}
}
v.clear();
for(int i = 1;i<=N;i++)g[i].clear();
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
992 KB |
Number of queries: 9 |
2 |
Correct |
8 ms |
736 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
752 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
752 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
12 ms |
508 KB |
Number of queries: 10 |
2 |
Correct |
12 ms |
760 KB |
Number of queries: 9 |
3 |
Partially correct |
11 ms |
1256 KB |
Number of queries: 10 |
4 |
Partially correct |
10 ms |
768 KB |
Number of queries: 10 |