답안 #676695

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676695 2022-12-31T17:55:26 Z LucaLucaM Easter Eggs (info1cup17_eastereggs) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<int>v[513];
vector<int>order;

void dfs (int x, int par)
{
    order.push_back(x);
    for (int i : v[x])
    {
        if (i == par)
            continue;
        dfs(i, x);
    }
}

int findEgg(int N, vector < pair < int, int > > bridges)
{
    for (pair<int, int>p : bridges)
    {
        v[p.first].push_back(p.second);
        v[p.second].push_back(p.first);
    }

    dfs(1, -1);

    int l=1, r=N;
    while (l < r)
    {
        int mid = (l + r) / 2;

        vector<int>curr;
        for (int i=0; i<mid; i++)
            curr.push_back(order[i]);

        if (query(curr))
            r = mid;
        else
            l = mid + 1;
    }
    
    int ret = order[r-1];
    for (int i=1; i<=n; i++)
        v[i].clear();
    order.clear();
    return ret;
}

Compilation message

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