#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int sze = 600;
vector<int> graph[sze];
vector<int> path;
void dfs(int node,int par=-1){
path.push_back(node);
for(auto v:graph[node]){
if(v==par){
continue;
}
dfs(v,node);
}
}
int findEgg(int n, vector<pair<int,int>> edges){
int ans=1;
path.clear();
for(int i=0;i<=n;i++){
graph[i].clear();
}
for(auto v:edges){
graph[v.first].push_back(v.second);
graph[v.second].push_back(v.first);
}
dfs(1);
int l =0;
int r = n-1;
vector<int> lst;
while(l<=r){
int mid = (l+r)/2;
lst.clear();
for(int i=0;i<=mid;i++){
lst.push_back(path[i]);
}
if(query(lst)){
ans=lst.back();
r = mid-1;
}
else{
l = mid+1;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
340 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Number of queries: 9 |
2 |
Correct |
6 ms |
748 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
9 ms |
600 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
11 ms |
600 KB |
Number of queries: 10 |
2 |
Correct |
10 ms |
344 KB |
Number of queries: 9 |
3 |
Partially correct |
9 ms |
596 KB |
Number of queries: 10 |
4 |
Partially correct |
9 ms |
344 KB |
Number of queries: 10 |