Submission #443717

# Submission time Handle Problem Language Result Execution time Memory
443717 2021-07-11T15:39:23 Z chicken337 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 484 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int MAXN = 513;
 
vector<int> adjlist[MAXN], v, vis(MAXN);
 
void dfs(int x=1){
    vis[x] = 1; v.push_back(x);
    for(int nxt : adjlist[x])
        if(!vis[nxt]) dfs(nxt);
}
int findEgg(int N, vector<pair<int, int>> bridges){
    for(int i = 0; i < N; i ++)
        adjlist[i].clear();
    fill(vis.begin(), vis.end(), 0);
    v.clear();
    for(pair<int, int> it : bridges){
        adjlist[it.first].push_back(it.second);
        adjlist[it.second].push_back(it.first);
    }
    dfs();
    int l = 0, r = N-1, ans = -1;
    while(l <= r){
        int m = (l + r) >> 1;
        if(query(vector<int>(v.begin(), v.begin()+m))){
            r = m-1; ans = m;
        } else l = m+1;
    }
    return v[ans];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 484 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -