Submission #743518

# Submission time Handle Problem Language Result Execution time Memory
743518 2023-05-17T13:13:57 Z AndrijaM Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

vector<int>g[513];
vector<int>a;

void dfs(int node,int par)
{
    a.push_back(node);
    for(auto idx:g[node])
    {
        if(idx!=par)
        dfs(idx,node);
    }
}

int findEgg (int N, vector < pair < int, int > > b)
{
    for(auto idx:b)
    {
        g[idx.first].push_back(idx.second);
        g[idx.second].push_back(idx.first);
    }
    dfs(1,-1);
    int l=0;
    int r=n-1;
    while(l<r)
    {
        int mid=l+(r-l)/2;
        if(query(vector<int>(a.begin(),a.begin()+mid)))r=mid;
        else
        {
            l=mid+1;
        }
    }
    return a[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:28:11: error: 'n' was not declared in this scope
   28 |     int r=n-1;
      |           ^