# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484223 | Alexandruabcde | Easter Eggs (info1cup17_eastereggs) | C++14 | 20 ms | 468 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;
constexpr int NMAX = 1000;
vector <int> G[NMAX];
vector <int> vec;
void Parcurgere_Euler (int Node, int Dad = -1) {
vec.push_back(Node);
for (auto it : G[Node]) {
if (it == Dad) continue;
Parcurgere_Euler(it, Node);
}
}
bool Check (int Right) {
vector <int> ask;
for (int i = 0; i <= Right; ++ i )
ask.push_back(vec[i]);
return query(ask);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
vec.clear();
for (int i = 1; i <= N; ++ i )
G[i].clear();
for (int i = 0; i < bridges.size(); ++ i ) {
int x = bridges[i].first;
int y = bridges[i].second;
G[x].push_back(y);
G[y].push_back(x);
}
Parcurgere_Euler(1, -1);
int st = 0, dr = vec.size()-2;
int ans = vec.size()-1;
while (st <= dr) {
int mij = (st + dr) / 2;
if (Check(mij)) {
dr = mij - 1;
ans = mij;
}
else st = mij + 1;
}
return vec[ans];
}
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... |