Submission #711447

# Submission time Handle Problem Language Result Execution time Memory
711447 2023-03-17T01:55:40 Z ooo Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
19 ms 356 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define fi first
#define se second
#define ll long long 
vector< vector<int> > g;
vector<int> thutu;
void dfs(int u, int t)
{   
    thutu.push_back(u);
    for(int i = 0; i < int(g[u].size()); ++i)
    {
        int v = g[u][i];
        if(v == t) continue;
        dfs(v, u);
    }
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
    g.clear();
    thutu.clear();
    g.resize(n+1);
    for(int i = 0; i < int(bridges.size()); ++i)
    {
        g[bridges[i].fi].push_back(bridges[i].se);
        g[bridges[i].se].push_back(bridges[i].fi);
    }

    dfs(1, 0);
    int l = 0; int r = n-1;
    while(l < r)
    {
        int mid = (l+r+1)/2;
        if(query(vector<int>(thutu.begin(), thutu.begin()+mid)))
            r = mid-1;
        else l = mid;
    }
    return thutu[l];
    return 0;
}
# 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 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 5 ms 336 KB Number of queries: 8
2 Correct 13 ms 348 KB Number of queries: 9
3 Correct 15 ms 352 KB Number of queries: 9
4 Correct 13 ms 336 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 17 ms 356 KB Number of queries: 9
2 Correct 19 ms 348 KB Number of queries: 9
3 Correct 15 ms 336 KB Number of queries: 9
4 Correct 15 ms 340 KB Number of queries: 9