#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 515;
const int inf=1234567890;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> adj[MAXN];
int n;
int pre[MAXN];
int cnt=1;
int rev[MAXN];
void reset(){
for(int i=0;i<=n;i++)adj[i].clear();
cnt=1;
memset(pre,0,sizeof pre);
memset(rev,0,sizeof rev);
}
void dfs(int x, int p){
pre[x]=cnt;
rev[cnt]=x;
cnt++;
for(auto v:adj[x])if(v!=p){
dfs(v,x);
}
}
bool check(int l){
vector<int> vec;
for(int i=1;i<=l;i++){
vec.push_back(rev[i]);
}
bool r=query(vec);
return r;
}
int dd(int n){
int t=0;
while(n>1){
n/=2;
t++;
}
return t;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
n=N;
if(n==1){
return 1;
}
for(auto x:bridges){
adj[x.first].push_back(x.second);
adj[x.second].push_back(x.first);
}
dfs(1,-1);
int logn=dd(n);
debug(logn);
int x=0;
for(int i=logn-1;i>=0;i--){
if(check(x+(1<<i))){
} else{
x+=1<<i;
}
}
++x;
int ans=rev[x];
reset();
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
284 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
352 KB |
Number of queries: 8 |
2 |
Runtime error |
2 ms |
464 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
376 KB |
Number of queries: 9 |
2 |
Correct |
11 ms |
384 KB |
Number of queries: 9 |
3 |
Correct |
14 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
368 KB |
Number of queries: 9 |