Submission #918047

# Submission time Handle Problem Language Result Execution time Memory
918047 2024-01-29T12:51:42 Z vjudge1 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
14 ms 1252 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
vector<vector<int>> g;
vector<int> order;
 
void dfs(int v, int prev, vector<int> &order, vector<vector<int>> &g)
{
    order.push_back(v);
 
    for(int i : g[v])
    {
        if(i == prev)continue;
 
        dfs(i, v, order, g);
    }
}
 
int query(vector < int > islands);
 
int findEgg(int n, vector<pair<int, int>> bridges)
{
    g.clear();
    order.clear();
    g.resize(n+1);
 
    for(auto &[u, v] : bridges)
    {
        g[u].push_back(v);
        g[v].push_back(u);
    }
 
    order.push_back(0);
    dfs(1, 0, order, g);
 
    int l = 1, r = n;
    while(l < r)
    {
        int mid = (l + r) >> 1;
 
        if(query(vector<int> (order.begin()+1, order.begin() + mid + 1)))
            r = mid;
        else
            l = mid + 1;
    }
    return order[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 596 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 4 ms 724 KB Number of queries: 8
2 Correct 8 ms 988 KB Number of queries: 9
3 Correct 14 ms 988 KB Number of queries: 9
4 Correct 11 ms 740 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1008 KB Number of queries: 9
2 Correct 11 ms 1252 KB Number of queries: 9
3 Correct 12 ms 988 KB Number of queries: 9
4 Correct 11 ms 496 KB Number of queries: 9