Submission #857424

# Submission time Handle Problem Language Result Execution time Memory
857424 2023-10-06T07:41:40 Z chilinhxyzabc Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
12 ms 756 KB
#include <bits/stdc++.h>
using namespace std;
 
vector<int> st;
vector<vector<int>> adj;
 
void dfs(int u, int p) {
    st.push_back(u);
    for(int v : adj[u]) {
        if(v == p)
            continue;
        dfs(v, u);
    }
}
 
int query(vector<int> islands);
 
int findEgg(int N, vector<pair<int,int>> bridges) {
    adj.clear();
    adj.resize(N + 1);
    for(auto[u, v] : bridges) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    st.clear();
    dfs(1, -1);
    int l = 1, r = N, res = 0;
    while(l <= r) {
        int m = (l + r) / 2;
        if(query(vector<int>(st.begin(), st.begin() + m))) {
            res = st[m - 1];
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Number of queries: 5
2 Partially correct 0 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 3 ms 724 KB Number of queries: 9
2 Correct 7 ms 732 KB Number of queries: 9
3 Correct 12 ms 732 KB Number of queries: 9
4 Correct 10 ms 732 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 12 ms 756 KB Number of queries: 10
2 Correct 10 ms 724 KB Number of queries: 9
3 Partially correct 11 ms 496 KB Number of queries: 10
4 Partially correct 11 ms 744 KB Number of queries: 10