#include <bits/stdc++.h>
#define ll long long
#define infInt (int)1e9 + 1
// #define infLL 0x3f3f3f3f3f3f
#define infLL (int)1e17
#define vt vector<int>
#define vtt vector<vt>
#define vttt vector<vtt>
#define vtttt vector<vttt>
#define pii pair<int, int>
#define vpii vector<pii>
#define endl '\n'
#define all(a) a.begin(), a.end()
#define _sort(a) sort(all(a))
#define bsUp(a, x) upper_bound(all(a), x) - a.begin()
#define bsLow(a, x) lower_bound(all(a), x) - a.begin()
#define rev(a) reverse(all(a))
#define uni(vals) vals.resize(distance(vals.begin(), unique(all(vals))))
// #define int ll
// #define in(a); ;
// #define hi ;
// #include "/home/phamngocthi/cp/see.cpp"
using namespace std;
vector<int> st;
vector<vector<int>> adj;
void dfs(int u, int p) {
st.push_back(u);
for(int v : adj[u]) {
if(v == p)
continue;
dfs(v, u);
}
}
int query(vector<int> islands);
int findEgg(int N, vector<pair<int,int>> bridges) {
adj.clear();
adj.assign(N + 1, vector<int>());
for(auto[u, v] : bridges) {
adj[u].push_back(v);
adj[v].push_back(u);
}
st.clear();
dfs(1, 0);
int l = 0, r = st.size() - 1, res = 0;
while(l <= r) {
int m = (l + r) / 2;
if(query(vector<int>(st.begin(), st.begin() + m + 1))) {
res = st[m];
r = m - 1;
} else {
l = m + 1;
}
}
return res;
}
// signed main() {
// ios_base::sync_with_stdio(false);cin.tie(NULL);
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
4 |
Partially correct |
0 ms |
344 KB |
Number of queries: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
976 KB |
Number of queries: 9 |
2 |
Correct |
8 ms |
980 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
724 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
1000 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
12 ms |
516 KB |
Number of queries: 10 |
2 |
Correct |
11 ms |
988 KB |
Number of queries: 9 |
3 |
Partially correct |
12 ms |
732 KB |
Number of queries: 10 |
4 |
Partially correct |
11 ms |
600 KB |
Number of queries: 10 |