Submission #384483

# Submission time Handle Problem Language Result Execution time Memory
384483 2021-04-01T17:53:09 Z ak2006 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 620 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
    a.pb(i);
    for (int c:adj[i]){
        if (c != p)
            dfs(c,i);
    }
}
int findEgg(int n,vector<pair<int,int>>b)
{
    for (int i = 0;i<=512;i++)adj[i].clear();
    a.clear();
    for (pair<int,int> i : b)adj[i.first].pb(i.second),adj[i.second].pb(i.first);
    dfs(1,1);
    int l = 1,r = n - 1,ans = 0;
    while (l <= r){
        int mid = (l + r)/2;
        if (query(vector<int>(a.begin(),a.begin() + mid))){
            r = mid - 1;
        }
        else l = mid + 1,ans = mid;
    }
    return a[ans + 1];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -