Submission #443713

# Submission time Handle Problem Language Result Execution time Memory
443713 2021-07-11T15:35:42 Z chicken337 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 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){
    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(0);
    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;
    }
    return v[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:14:24: error: 'n' was not declared in this scope
   14 |     for(int i = 0; i < n; i ++)
      |                        ^