#include<bits/stdc++.h>
#include "grader.h"
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll sz = 550;
vi g[sz];
vi order;
int vis[sz];
void dfs(int node)
{
vis[node] = 1;
order.pb(node);
for(auto u : g[node])
{
if(!vis[u])
dfs(u);
}
}
int findEgg(int N, vector<pair<int, int>> bridges)
{
for(int i = 1; i <= N; i++)
g[i].clear();
order.clear();
for(auto x : bridges){
g[x.f].pb(x.s);
g[x.s].pb(x.f);
}
dfs(1);
int l = 0, r = N - 1;
while(l != r)
{
int mid = (l + r + 1) / 2;
if(query(vi(order.begin(), order.begin() + mid))) r = mid - 1;
else l = mid;
}
return order[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
732 KB |
Number of queries: 8 |
2 |
Correct |
7 ms |
732 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
1000 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
1256 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
760 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
1012 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
732 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
1004 KB |
Number of queries: 9 |