#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int maxn = 1010;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n;
vector <int> question;
int dau[maxn],s[maxn];
vector <int> adj[maxn],comp;
void dfs(int x, int p)
{
comp.push_back(x);
for (int i:adj[x])
if (i!=p) dfs(i,x);
}
int findEgg(int N, vector <ii> bridges)
{
n=N;
question.clear();
for (int i=1; i<=n; i++) adj[i].clear();
for (ii i:bridges)
{
adj[i.ff].push_back(i.ss);
adj[i.ss].push_back(i.ff);
}
dfs(1,1);
int l=0; int r=n-1;
int ans = -1;
while (l<=r)
{
int mid=(l+r)/2;
vector <int> tmp;
for (int i=0; i<=mid; i++) tmp.push_back(comp[i]);
if (query(tmp))
{
ans=mid;
r=mid-1;
}
else l=mid+1;
}
return comp[ans];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
332 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
328 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
328 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
360 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
444 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
460 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
544 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
22 ms |
592 KB |
Number of queries: 10 |
2 |
Correct |
13 ms |
564 KB |
Number of queries: 9 |
3 |
Partially correct |
14 ms |
456 KB |
Number of queries: 10 |
4 |
Partially correct |
15 ms |
580 KB |
Number of queries: 10 |