#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=600;
vector<int> vec,G[N],ask;
void dfs(int u,int p) {
vec.pb(u);
fa (v,G[u]) if (v!=p) dfs(v,u);
}
int findEgg(int n,vector<pair<int,int>> bridges) {
vec.clear();
fw (i,1,n+1) G[i].clear();
fa (i,bridges) {
G[i.fi].pb(i.se);
G[i.se].pb(i.fi);
}
dfs(1,0);
int l=0,r=n-1;
while (l<r) {
int mid=(l+r)/2;
ask.clear();
fw (i,0,mid+1) ask.pb(vec[i]);
if (query(ask)) r=mid;
else l=mid+1;
}
return vec[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Number of queries: 4 |
2 |
Correct |
3 ms |
436 KB |
Number of queries: 4 |
3 |
Correct |
3 ms |
436 KB |
Number of queries: 4 |
4 |
Correct |
3 ms |
436 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Number of queries: 8 |
2 |
Correct |
17 ms |
540 KB |
Number of queries: 9 |
3 |
Correct |
22 ms |
544 KB |
Number of queries: 9 |
4 |
Correct |
16 ms |
568 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
568 KB |
Number of queries: 9 |
2 |
Correct |
36 ms |
572 KB |
Number of queries: 9 |
3 |
Correct |
34 ms |
572 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
708 KB |
Number of queries: 9 |