Submission #863909

# Submission time Handle Problem Language Result Execution time Memory
863909 2023-10-21T11:51:57 Z Ariadna Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
13 ms 856 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int query(vector < int > islands);
 
vector < vector < int > > adj;
 
void dfs(int u, int p, vector < int >& order) {
    order.push_back(u);
    for (int v : adj[u]) {
        if (v != p) dfs(v, u, order);
    }
}
 
int findEgg(int N, vector < pair < int, int > > bridges) {
    adj = vector < vector < int > >(N + 1);
    for (int i = 0; i < N - 1; ++i) {
        int u = bridges[i].first, v = bridges[i].second;
        adj[u].push_back(v);
        adj[v].push_back(u);   
    }
 
    vector < int > order;
    dfs(1, 1, order);
 
    int l = 0, r = N - 1;
    while (l < r) {
        vector < int > q;
        int m = (l + r) / 2;
        for (int i = 0; i <= m; ++i) {
            q.push_back(order[i]);
        }
        if (query(q)) r = m;
        else l = m + 1;
    }
    return order[l];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Number of queries: 4
2 Correct 0 ms 428 KB Number of queries: 4
3 Correct 1 ms 436 KB Number of queries: 4
4 Correct 1 ms 436 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 4 ms 736 KB Number of queries: 8
2 Correct 8 ms 492 KB Number of queries: 9
3 Correct 12 ms 732 KB Number of queries: 9
4 Correct 10 ms 740 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 13 ms 856 KB Number of queries: 9
2 Correct 12 ms 740 KB Number of queries: 9
3 Correct 12 ms 504 KB Number of queries: 9
4 Correct 11 ms 736 KB Number of queries: 9