Submission #802713

# Submission time Handle Problem Language Result Execution time Memory
802713 2023-08-02T13:34:30 Z raysh07 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
16 ms 536 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
int n;
const int maxn = 513;
vector <int> adj[maxn];
vector <int> ok;

void dfs(int u, int par = -1){
    ok.push_back(u);
    for (int v : adj[u]){
        if (v != par){
            dfs(v, u);
        }
    }
}
 
int findEgg (int N, vector <pair<int,int>> bridges)
{
    n = N;
    for (int i = 1; i <= n; i++) adj[i].clear();
    
    for (auto [u, v] : bridges){
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    dfs(1);
    
    int l = 0, r = n - 1;
    
    while (l != r){
        int mid = (l + r)/2;
        
        vector <int> lol;
        for (int i = 0; i <= mid; i++) lol.push_back(ok[i]);
        
        if (query(lol)) r = mid;
        else l = mid + 1;
    }
    
    return ok[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 312 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Number of queries: 8
2 Correct 8 ms 336 KB Number of queries: 9
3 Correct 13 ms 536 KB Number of queries: 9
4 Correct 16 ms 444 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 14 ms 464 KB Number of queries: 9
2 Correct 12 ms 444 KB Number of queries: 9
3 Correct 13 ms 488 KB Number of queries: 9
4 Correct 16 ms 452 KB Number of queries: 9