Submission #895620

# Submission time Handle Problem Language Result Execution time Memory
895620 2023-12-30T11:49:38 Z maxFedorchuk Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
11 ms 1872 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
using ll = long long;
 
vector<int> v[1010], l;
 
void dfs(int u, int p) {
    l.push_back(u);
    for(auto x : v[u]) if(x != p) dfs(x, u);
}
 
int findEgg(int N, vector<pair<int, int>> bridges) {
    for(int i=1;i<=N;i++) v[i].clear();
    for(auto [x, y] : bridges) v[x].push_back(y), v[y].push_back(x);
    dfs(1, 0);
 
    int L = 0, R = N-2;
    while(L <= R) {
        int M = (L+R)/2;
        if(query(vector<int>(l.begin(), l.begin()+M+1))) R = M-1;
        else L = M+1;
    }
    return l[L];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB Number of queries: 4
2 Correct 0 ms 456 KB Number of queries: 4
3 Correct 0 ms 464 KB Number of queries: 4
4 Correct 0 ms 460 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 740 KB Number of queries: 8
2 Correct 7 ms 1272 KB Number of queries: 9
3 Correct 11 ms 1516 KB Number of queries: 9
4 Correct 10 ms 1008 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1540 KB Number of queries: 9
2 Correct 9 ms 1108 KB Number of queries: 9
3 Correct 10 ms 1300 KB Number of queries: 9
4 Correct 10 ms 1872 KB Number of queries: 9