#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pb push_back
#define pl pair<ll,int>
#define ll long long
#define f first
#define s second
#define pi pair<int,int>
const int MAX = 514;
vector<int>nodes;
vector<int>g[MAX];
void dfs(int u, int p){
nodes.pb(u);
for(int i : g[u]){
if(i==p) continue;
dfs(i,u);
}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
for(int i = 1; i<=N; i++) g[i].clear();
nodes.clear();
for(pi i: bridges){
g[i.f].pb(i.s);
g[i.s].pb(i.f);
}
dfs(1,0);
int l = 0, r=N-1;
while(l<r){
int m = (l+r+1)/2;
bool ans = query(vector<int>(nodes.begin(), nodes.begin()+m));
if(ans){
r = m-1;
}
else l = m;
}
//cout << "fsdfd"<< endl;
return nodes[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
500 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 |
984 KB |
Number of queries: 8 |
2 |
Correct |
7 ms |
856 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
476 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
484 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1004 KB |
Number of queries: 9 |
2 |
Correct |
9 ms |
928 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
988 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
604 KB |
Number of queries: 9 |