Submission #901506

# Submission time Handle Problem Language Result Execution time Memory
901506 2024-01-09T13:36:52 Z ivaziva Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 504 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

#define MAXN 520

long long n;
vector<long long> adj[MAXN];
vector<long long> nodes;
vector<int> vec;

void dfs(long long node,long long pret)
{
    nodes.push_back(node);
    long long s=adj[node].size();
    for (long long i=0;i<s;i++)
    {
        long long sled=adj[node][i];
        if (sled!=pret) dfs(sled,node);
    }
}

bool check(long long mid)
{
    for (long i=0;i<=mid;i++) vec.push_back(nodes[i]);
    long long ans=query(vec);vec.clear();
    if (ans==1) return true;
    return false;
}

int findEgg(int N, vector < pair < int, int > > bridges)
{
    n=N;nodes.clear();
    for (long long i=0;i<MAXN;i++) adj[i].clear();
    for (long long i=0;i<n-1;i++)
    {
        long long x=bridges[i].first;
        long long y=bridges[i].second;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1,0);
    long long l=0;
    long long r=n-1;
    while (l!=r)
    {
        long long mid=(l+r+1)/2;
        if (check(mid)) r=mid-1;
        else l=mid;
    }
    return nodes[l];
};
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 504 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -