This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// omfg why would you use namespace std in a header file like are you ok?????????
// bro why the fuck are you segfaultingggg
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
//#include "grader.h"
int findEgg(int n, std::vector<std::pair<int,int>> bridges);
int query(std::vector<int> islands);
void dfs(int k, int p, const std::vector<int>* adj_list, std::vector<int>& tour) {
tour.emplace_back(k);
for (const auto& i : adj_list[k]) {
if (i!=p) {
dfs(i,k,adj_list,tour);
tour.emplace_back(k);
}
}
}
int findEgg(int n, std::vector<std::pair<int,int>> bridges) {
// these testcases are actually fucking retarded, nodes can go above n, like that makes no sense and it's not mentioned in the statement
// bs problem, average info1cup experience
std::vector<int> adj_list[513];
std::vector<int> tour;
int gs = n;
for (int i = 0; i < 513; i++) {
adj_list[i].clear();
}
tour.clear();
for (const auto& [a, b] : bridges) {
adj_list[a].emplace_back(b);
adj_list[b].emplace_back(a);
}
dfs(1,0,adj_list,tour);
int l = 0, r = tour.size()-1;
int ret = 0;
while (l<=r) {
int m = (l+r)/2;
if (query(std::vector<int>(tour.begin(),tour.begin()+m+1))) {
ret = m;
r = m-1;
}
else {
l = m+1;
}
}
ret = tour[ret];
return ret;
}
Compilation message (stderr)
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:35:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
35 | for (const auto& [a, b] : bridges) {
| ^
eastereggs.cpp:30:6: warning: unused variable 'gs' [-Wunused-variable]
30 | int gs = n;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |