# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
660272 | BlancaHM | Easter Eggs (info1cup17_eastereggs) | C++14 | 21 ms | 584 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> order;
vector<vector<int>> listaAdy;
void dfs(int nodo, int padre){
order.push_back(nodo);
for(int vecino: listaAdy[nodo]){
if(vecino == padre) continue;
dfs(vecino, nodo);
}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
listaAdy = vector<vector<int>>(N+1);
for(pair<int, int> bridge: bridges){
listaAdy[bridge.second].push_back(bridge.first);
listaAdy[bridge.first].push_back(bridge.second);
}
dfs(1, -1);
int ans = N;
int lo = 1; int hi = N-1;
vector<int> ask((N)/2);
for(int i = 0; i < (N)/2; ++i) ask[i] = order[i];
while(hi >= lo){
int mid = (hi + lo)/2;
while(ask.size() < (mid)){
ask.push_back(order[ask.size()]);
}
while(ask.size() > (mid)) ask.pop_back();
if(query(ask)){
hi = mid-1;
ans = mid;
}
else{
lo = mid+1;
}
}
return order[ans-1];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |