Submission #836309

# Submission time Handle Problem Language Result Execution time Memory
836309 2023-08-24T10:04:24 Z KALARRY Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 588 KB
//chockolateman

#include<bits/stdc++.h>
#include "grader.h"

using namespace std;

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(int i = 1 ; i <= N ; i++)
    {
        adj[i].clear();
        scores[i] = 1;
    }
    for(auto e : bridges)
    {
        int a = e.first;
        int b = e.second;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    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;    
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -