Submission #484261

# Submission time Handle Problem Language Result Execution time Memory
484261 2021-11-02T18:01:49 Z Tenis0206 Easter Eggs (info1cup17_eastereggs) C++11
0 / 100
7 ms 5252 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int cnt = 0;

int n;

vector<int> G[100005];

int p[100005],fr[100005];

/*int ou = 0;

bool query(vector<int> v)
{
    for(auto it : v)
    {
        if(it==ou)
        {
            return true;
        }
    }
    return false;
}
*/

void dfs(int nod, int dad = 0)
{
    p[++cnt] = nod;
    for(auto it : G[nod])
    {
        if(it==dad)
        {
            continue;
        }
        dfs(it,nod);
     //   p[++cnt] = nod;
    }
}

vector<int> get_query(int st, int dr)
{
    vector<int> rez;
    for(int i=st;i<=dr;i++)
    {
        if(!fr[p[i]])
        {
            rez.push_back(p[i]);
        }
        ++fr[p[i]];
    }
    for(int i=st;i<=dr;i++)
    {
        fr[p[i]] = 0;
    }
    return rez;
}

int findEgg(int N, vector<pair<int,int>> e)
{
    n = N;
    for(auto it : e)
    {
        int x = it.first;
        int y = it.second;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1);
    int st = 1;
    int dr = 2 * n - 1;
    while(st<dr)
    {
        int mij = (st+dr)>>1;
        vector<int> q = get_query(st,mij);
        if(query(q))
        {
            dr = mij;
        }
        else
        {
            st = mij+1;
        }
    }
    cnt = 0;
    for(int i=1;i<=n;i++)
    {
        G[i].clear();
    }
    return p[st];
}

/*int main()
{
    int n;
    cin>>n>>ou;
    vector<pair<int,int>> e;
    for(int i=1;i<n;i++)
    {
         int x,y;
         cin>>x>>y;
         e.push_back({x,y});
    }
    cout<<findEgg(n,e);
    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 2632 KB Number of queries: 5
2 Runtime error 6 ms 5208 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 5192 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 5252 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -