Submission #671507

# Submission time Handle Problem Language Result Execution time Memory
671507 2022-12-13T06:12:40 Z wenqi Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
262 ms 131072 KB
// trans rights
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

vector<int> adj[1069];
vector<int> H;

void dfs(int i, int p)
{
    H.push_back(i);
    for (int j : adj[i])
    {
        if (j == p) continue;
        dfs(j, i);
    }
}

bool within(int x)
{
    vector<int> q;
    for (int i = 0; i <= x; i++)
        q.push_back(H[i]);
    return query(q);
}

int findEgg(int N, vector<pair<int, int>> bridges)
{
    for (int i = 0; i < N - 1; i++)
    {
        int a = bridges[i].first;
        int b = bridges[i].second;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1, 1);
    int a = 0;
    int b = N;
    while (b - a > 1)
    {
        int m = (a + b) / 2;
        if (within(m - 1)) b = m;
        else a = m;
    }
    return H[a];
}
# Verdict Execution time Memory Grader output
1 Runtime error 262 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 207 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 201 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -