#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[600];
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 |
Correct |
3 ms |
992 KB |
Number of queries: 8 |
2 |
Correct |
8 ms |
988 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
744 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
484 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
760 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
988 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
992 KB |
Number of queries: 9 |
4 |
Correct |
11 ms |
1000 KB |
Number of queries: 9 |