#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)
{
for (int i = 0; i < N; ++ 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()-1;
int ans = 0;
while (st <= dr) {
int mij = (st + dr) / 2;
if (Check(mij)) {
dr = mij - 1;
ans = mij;
}
else st = mij + 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
198 ms |
131076 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |