제출 #443713

#제출 시각아이디문제언어결과실행 시간메모리
443713chicken337Easter Eggs (info1cup17_eastereggs)C++14
컴파일 에러
0 ms0 KiB
#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];
}

컴파일 시 표준 에러 (stderr) 메시지

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 ++)
      |                        ^