#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
vi order;
vvi graph;
void dfs(int x, int p) {
order.pb(x);
for(auto e : graph[x]) {
if(e != p) dfs(e, x);
}
}
vi slic(vi &vec, int r) {
vi out;
frange(i, r+1) {
out.pb(vec[i]);
}
return out;
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
graph = vvi(n+1);
for(auto p : bridges) {
graph[p.f].pb(p.s);
graph[p.s].pb(p.f);
}
dfs(1, 0);
int lo = 0;
int hi = n-1;
while(lo != hi) {
int mid = (lo+hi)/2;
if(!query(slic(order, mid))) lo = mid+1;
else hi = mid;
}
return order[lo];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
432 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
436 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
436 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
436 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
736 KB |
Number of queries: 8 |
2 |
Correct |
10 ms |
1236 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
932 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
1172 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1336 KB |
Number of queries: 9 |
2 |
Correct |
11 ms |
992 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
1168 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
1552 KB |
Number of queries: 9 |