//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(scores[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;
temp = target;
int start = -1;
for(int i = 1 ; i <= N ; i++)
if(scores[i]==1)
start = i;
dfs(start,start);
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);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
688 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
182 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
178 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |