#include <bits/stdc++.h>
#include "grader.h"
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
typedef pair <int, int> pii;
const int Inf = 100000;
const int mod = 998244353;
const double Pi = acos(-1);
void Fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
vector <int> DFSorder;
vector <int> Adj[525];
void DFS(int node, int p = -1)
{
DFSorder.eb(node);
for(auto x : Adj[node])
{
if(x != p)
{
DFS(x, node);
}
}
}
int findEgg(int n, vector <pii> bridges)
{
for(int i = 1; i <= n; i++)
{
Adj[i].clear();
}
for(auto x : bridges)
{
Adj[x.fi].eb(x.se);
Adj[x.se].eb(x.fi);
}
DFSorder.clear();
DFS(1);
int l = 0, r = n - 1;
while(l < r)
{
int mid = (l + r) >> 1;
vector <int> Ans;
Ans.clear();
for(int i = 0; i <= mid; i++)
{
Ans.eb(DFSorder[i]);
}
if(query(Ans))
{
r = mid;
}
else
{
l = mid + 1;
}
}
return DFSorder[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Number of queries: 4 |
2 |
Correct |
5 ms |
384 KB |
Number of queries: 4 |
3 |
Correct |
6 ms |
384 KB |
Number of queries: 4 |
4 |
Correct |
5 ms |
384 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
384 KB |
Number of queries: 8 |
2 |
Correct |
15 ms |
384 KB |
Number of queries: 9 |
3 |
Correct |
27 ms |
384 KB |
Number of queries: 9 |
4 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |
2 |
Correct |
21 ms |
512 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |
4 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |