#include "bits/stdc++.h"
#include "grader.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
using ll = long long;
const int mod = 1e9+7;
void dfs(int u, int p, vector<vector<int>> &adj, vector<int> &o) {
o.push_back(u);
for (int v : adj[u])
if (v != p)
dfs(v, u, adj, o);
}
int findEgg(int n, vector<pair<int, int>> bridges) {
vector<vector<int>> adj(n+1);
vector<int> o;
for (auto [u, v] : bridges) {
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(0, -1, adj, o);
int l = 0, r = n;
auto chk = [&] (int m) -> bool {
vector<int> v(o.begin(), o.begin() + m);
return query(v);
};
while (l < r) {
int m = (l + r) / 2;
if (chk(m)) {
r = m;
} else {
l = m+1;
}
}
return o[r];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |