Submission #951886

# Submission time Handle Problem Language Result Execution time Memory
951886 2024-03-22T21:56:49 Z __Davit__ Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
14 ms 1244 KB
#include "grader.h"
#include <bits/stdc++.h>

using namespace std;
namespace {
    vector<vector<int>> gp;
    vector<int> order;

    void dfs(int node = 1, int parent = 0) {
        order.push_back(node);
        for (int i: gp[node])if (i != parent) dfs(i, node);
    }
}

int findEgg(int N, vector<pair<int, int>> bridges) {
    gp.clear();
    gp.resize(N + 11);
    order.clear();
    for (pair<int, int> i: bridges) {
        gp[i.first].push_back(i.second);
        gp[i.second].push_back(i.first);
    }
    dfs();
    int ina = 1, inb = N, ans = order.back();
    while (ina <= inb) {
        int mid = (ina + inb) / 2;
        if (query(vector<int>(order.begin(), order.begin() + mid))) {
            inb = mid - 1;
            ans = *(order.begin() + mid - 1);
        } else ina = mid + 1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Number of queries: 5
2 Partially correct 1 ms 344 KB Number of queries: 5
3 Partially correct 1 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 4 ms 724 KB Number of queries: 9
2 Correct 8 ms 984 KB Number of queries: 9
3 Correct 14 ms 988 KB Number of queries: 9
4 Correct 12 ms 992 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 13 ms 1012 KB Number of queries: 10
2 Correct 10 ms 476 KB Number of queries: 9
3 Partially correct 11 ms 1244 KB Number of queries: 10
4 Partially correct 11 ms 744 KB Number of queries: 10