// omfg why would you use namespace std in a header file like are you ok?????????
#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<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) {
std::vector<std::vector<int>> adj_list;
std::vector<int> tour;
int gs = n;
adj_list.resize(gs+1);
for (const auto& [a, b] : bridges) {
adj_list[a].emplace_back(b);
adj_list[b].emplace_back(a);
}
return n;
dfs(1,0,adj_list,tour);
int l = 0, r = tour.size()-1;
int ret = 0;
while (l<=r) {
int m = (l+r)/2;
std::vector<int> tmp;
for (int i = 0; i <= m; i++) {
tmp.emplace_back(tour[i]);
}
if (query(tmp)) {
ret = m;
r = m-1;
}
else {
l = m+1;
}
}
ret = tour[ret];
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |