Submission #1288728

#TimeUsernameProblemLanguageResultExecution timeMemory
1288728cpismayilmmdv985Easter Eggs (info1cup17_eastereggs)C++20
100 / 100
8 ms500 KiB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

const int MXN = 1000;
vector<int> adj[MXN], order;

void dfs(int node, int parent = 0) {
    order.push_back(node);
    for (auto &child : adj[node])   if (child != parent)    dfs(child, node);
}

int findEgg(int N, vector<pair<int, int>> bridges) {
    for (int i = 1; i <= N; i++)    adj[i].clear();
    order.clear();
    for (auto &i : bridges)         adj[i.first].push_back(i.second), adj[i.second].push_back(i.first);
    dfs(1);
    int low = 0, high = N - 1, mid;
    vector<int> Q;
    while (low < high) {
        mid = (low + high) >> 1, Q.clear();
        for (int i = 0; i <= mid; i++)  Q.push_back(order[i]);
        if (query(Q))   high = mid;
        else            low = mid + 1;
    }
    return order[high];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...