Submission #711442

# Submission time Handle Problem Language Result Execution time Memory
711442 2023-03-17T01:43:52 Z ooo Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 668 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define fi first
#define se second
#define ll long long 
vector< vector<int> > g;
vector<int> doan[605];
ll child[605], ma[605];
ll par[605], head[605];
void dfs(ll u, ll t)
{
    for(int i = 0; i < int(g[u].size()); ++i)
    {
        ll v = g[u][i];
        if(v == t) continue;
        par[v] = u;
        dfs(v, u);
        if(child[v]+1 > child[u])
        {
            child[u] = child[v]+1;
            ma[u] = v;
        }
    }
}
void hld(ll u)
{
    if(ma[par[u]] == u) head[u] = head[par[u]];
    else head[u] = u;

    doan[head[u]].push_back(u);
    if(ma[u] > 0) hld(ma[u]);
    for(int i = 0; i < int(g[u].size()); ++i)
    {
        ll v = g[u][i];
        if(v != par[u] && v != ma[u]) hld(v);
    }
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
    g.clear();
    for(int i = 1; i <= 600; ++i)
        doan[i].clear();
    g.resize(n+1);
    for(int i = 0; i < int(bridges.size()); ++i)
    {
        g[bridges[i].fi].push_back(bridges[i].se);
        g[bridges[i].se].push_back(bridges[i].fi);
    }

    dfs(1, 0);
    hld(1);

    ll pos = 0;
    for(int i = 1; i <= n; ++i)
    if(int(doan[i].size()) > 0)
    {
        if(query(doan[i]))
        {
            pos = i;
            break;
        }
    }

    ll l = 0; ll r = int(doan[pos].size())-1;
    while(l < r)
    {
        ll mid = (l+r)/2;
        if(query(vector<int>(doan[pos].begin(), doan[pos].begin()+mid)))
            r = mid;
        else l = mid+1;
    }
    return doan[pos][l];
    return 0;
}
# 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 2 ms 668 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -