#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vll vector<ll>
#define all(v) v.begin(), v.end()
#define whole(a) a+1, a+1+n
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec second
#define fi first
#define print(k) cerr << "Ans : "; cout << k << endl;
#define ins insert
#define pb push_back
#define bpc __builtin_popcountll
#define skip continue
#define endll '\n'
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a*b / (__gcd(a, b))
#define mpr make_pair
#define rep(i,l,r) for(ll i=l;i<=r;++i)
#define new '\n'
typedef long long ll;
typedef unsigned long long ull;
const int mod = 998244353;
const int sz = 3e5+5;
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
vector<int>v;
vector<int>g[60];
void dfs(int node, int par)
{
v.pb(node);
for(int i:g[node])
{
if(i == par)
{
continue;
}
dfs(i, node);
}
}
int findEgg (int n, vector<pair<int, int>> b)
{
v.clear();
for(int i = 0; i <= n; ++i)
{
g[i].clear();
}
for(pii p:b)
{
g[p.first].pb(p.second);
g[p.second].pb(p.first);
}
dfs(1, 1);
int l = 0, r = v.size()-1;
while(l < r)
{
int mid = ( l + r ) >> 1;
vector<int> w;
for( int i = 0; i <= mid; ++i){
w.pb(v[i]);
}
if(query(w))
{
r = mid;
}
else{
l = mid + 1;
}
}
return v[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 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |