이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 512;
vector<int> adj[N];
vector<int> order;
void dfs(int node, int p = -1){
order.emplace_back(node);
for (int i:adj[node]){
if (i != p){
dfs(i,node);
}
}
}
int findEgg (int N, vector < pair < int, int > > bridges){
for (int i=0; i<N; ++i){
adj[i].clear();
}
order.clear();
for (auto [a,b]:bridges){
a--; b--;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
dfs(0);
int deb = 0, fin = N-1;
while (deb < fin){
int mid = (deb+fin)/2;
vector<int> q;
for (int i=0; i<=mid; ++i){
q.emplace_back(order[i]+1);
}
if (query(q)){
fin = mid;
}
else{
deb = mid+1;
}
}
return order[deb]+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |