#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
const int inf = 1e3+9;
vector<int> DfsOrder,adj[inf];
void dfs(int u,int p){
DfsOrder.pb(u);
for(auto v:adj[u])
if(v != p)
dfs(v,u);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(int i=0;i<n;i++)
adj[i].clear();
DfsOrder.clear();
for(auto o:bridges)
adj[o.first].pb(o.second),
adj[o.second].pb(o.first);
dfs(1,-1);
int l = 0,r = n-1;
while(r!=l){
int mid = (l+r)/2;
if(query(vector<int>(DfsOrder.begin(),DfsOrder.begin()+mid+1)))
r = mid;
else
l = mid+1;
}
return DfsOrder[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
336 KB |
Number of queries: 8 |
2 |
Runtime error |
2 ms |
456 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
516 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |