Submission #61584

# Submission time Handle Problem Language Result Execution time Memory
61584 2018-07-26T07:44:40 Z FutymyClone Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
38 ms 580 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int N = 515;
vector <int> g[N], vertices;
int n, a[N];

void dfs (int u, int p) {
    vertices.push_back(u);
    for (int v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
    }
}

int findEgg (int N, vector <pair <int, int> > bridges) {
    n = N;
    vertices.clear();
    for (int i = 1; i <= n; i++) g[i].clear();
    for (auto i: bridges) {
        g[i.first].push_back(i.second);
        g[i.second].push_back(i.first);
    }

    dfs(1, 1);

    int l = 1;
    int r = n;

    vector <int> islands;
    while (l <= r) {
        int mid = (l + r) / 2;
        islands.clear();
        for (int i = 1; i <= mid; i++) {
            islands.push_back(vertices[i - 1]);
        }

        if (query(islands)) r = mid - 1;
        else l = mid + 1;
    }

    return vertices[l - 1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 248 KB Number of queries: 5
2 Incorrect 3 ms 436 KB Number of queries: 5
3 Incorrect 3 ms 436 KB Number of queries: 5
4 Incorrect 3 ms 436 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 10 ms 436 KB Number of queries: 9
2 Correct 19 ms 436 KB Number of queries: 9
3 Correct 27 ms 436 KB Number of queries: 9
4 Correct 24 ms 512 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 512 KB Number of queries: 10
2 Correct 36 ms 544 KB Number of queries: 9
3 Incorrect 37 ms 548 KB Number of queries: 10
4 Incorrect 38 ms 580 KB Number of queries: 10