#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "grader.h"
int n;
VVI gp;
VI euler;
void dfs(int u = 0, int p = -1) {
euler.pb(u+1);
for (int v : gp[u]) if (v != p) dfs(v, u);
}
bool qr(int x) {
VI tmp;
replr(i, 0, x) tmp.pb(euler[i]);
return query(tmp);
}
int findEgg(int N, VPI bridges) {
n = N;
gp = VVI(n);
for (auto[u, v] : bridges) {
u--, v--;
gp[u].pb(v);
gp[v].pb(u);
}
dfs();
int l = -1, r = n-1;
while (l + 1 < r) {
int m = (l + r) / 2;
if (qr(m)) r = m;
else l = m;
}
return euler[r];
}
Compilation message
eastereggs.cpp: In function 'int findEgg(int, VPI)':
eastereggs.cpp:52:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
52 | for (auto[u, v] : bridges) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
444 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
432 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
436 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
432 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1244 KB |
Number of queries: 8 |
2 |
Correct |
9 ms |
740 KB |
Number of queries: 9 |
3 |
Correct |
15 ms |
1428 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
1012 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1580 KB |
Number of queries: 9 |
2 |
Correct |
15 ms |
1012 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
1800 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
1392 KB |
Number of queries: 9 |