#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> e;
vector <int> adj[600];
void dfs(int node,int par)
{
e.push_back(node);
for(int i:adj[node])
{
if(i==par) continue;
dfs(i,node);
}
}
int findEgg(int n,vector<pair<int,int>> bridges)
{
e.clear();
for(int i=0;i<=n;i++)
adj[i].clear();
for(pair <int,int> p: bridges)
{
adj[p.first].push_back(p.second);
adj[p.second].push_back(p.first);
}
dfs(1,1);
int l=0,r=e.size()-1;
while (l < r)
{
int mid = (l + r) >> 1;
vector<int> nw;
for (int i = 0; i <= mid; i++) nw.push_back(e[i]);
if (query(nw)) r = mid;
else l = mid + 1;
}
return e[l];
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
728 KB |
Number of queries: 8 |
2 |
Correct |
9 ms |
1244 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
1000 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
744 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
760 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
1004 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
1000 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
736 KB |
Number of queries: 9 |