#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
a.pb(i);
for (int c:adj[i]){
if (c == p)continue;
dfs(c,i);
}
}
int findEgg(int n,vector<pair<int,int>>b)
{
for (int i = 0;i<=512;i++)adj[i].clear();
a.clear();
for (int i = 0;i<n - 1;i++)adj[b[i].first].pb(b[i].second);
dfs(1,1);
int l = 0,r = n - 1,ans = 1;
while (l <= r){
int mid = (l + r)/2;
if (query(vector<int>(a.begin(),a.begin() + mid))){
r = mid - 1;
}
else l = mid + 1,ans = mid + 1;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
528 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |