Submission #470999

# Submission time Handle Problem Language Result Execution time Memory
470999 2021-09-06T15:00:20 Z vishesh312 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 456 KB
#include "bits/stdc++.h"
#include "grader.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()

using ll = long long;
const int mod = 1e9+7;

void dfs(int u, int p, vector<vector<int>> &adj, vector<int> &o) {
    o.push_back(u);
    for (int v : adj[u])
        if (v != p)
            dfs(v, u, adj, o);
}

int findEgg(int n, vector<pair<int, int>> bridges) {
    vector<vector<int>> adj(n+1);
    vector<int> o;
    for (auto [u, v] : bridges) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(0, -1, adj, o);
    int l = 0, r = n;
    auto chk = [&] (int m) -> bool {
        vector<int> v(o.begin(), o.begin() + m);
        return query(v);
    };
    while (l < r) {
        int m = (l + r) / 2;
        if (chk(m)) {
            r = m;
        } else {
            l = m+1;
        }
    }
    return o[r];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -