//chockolateman
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
int ans;
vector<int> adj[520];
int scores[520];
int target,temp;
vector<int> queries;
void dfs(int v,int p)
{
if(score[v]==0)
return;
temp -= scores[v];
queries.push_back(v);
if(temp==0)
return;
for(auto u : adj[v])
if(u!=p)
dfs(u,v);
}
int findEgg(int N,vector<pair<int,int>> bridges)
{
for(auto e : bridges)
{
int a = e.first;
int b = e.second;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i = 1 ; i <= N ; i++)
scores[i] = 1;
target = N;
while(target>1)
{
queries.clear();
target/=2;
//printf("targ = %d\n",target);
temp = target;
dfs(1,1);
int res = query(queries);
if(res==0)
for(auto u : queries)
scores[u] = 0;
else
{
for(auto u : queries)
scores[u]++;
for(int i = 1 ; i <= N ; i++)
{
if(scores[i]==1)
scores[i] = 0;
if(scores[i]==2)
scores[i] = 1;
}
}
}
int egg = -1;
for(int i = 1 ; i <= N ; i++)
if(scores[i]==1)
egg = i;
return egg;
}
// int main()
// {
// int N;
// scanf("%d",&N);
// vector<pair<int,int>> edges;
// for(int a,b,i = 1 ; i < N ; i++)
// {
// scanf("%d%d",&a,&b);
// edges.push_back({a,b});
// }
// scanf("%d",&ans);
// printf("IN\n");
// int res = findEgg(N,edges);
// if(res==ans)
// printf("Correct\n");
// else
// printf("WA answered %d\n",res);
// }
Compilation message
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:17:8: error: 'score' was not declared in this scope; did you mean 'scores'?
17 | if(score[v]==0)
| ^~~~~
| scores