Submission #446603

# Submission time Handle Problem Language Result Execution time Memory
446603 2021-07-22T16:17:02 Z blue Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include "grader.h"
using namespace std;

const int maxN = 512;

vector<int> edge[1+maxN];

vector<int> order;
vector<int> visit(1+maxN, 0);

void dfs(int u)
{
    if(visit[u]) return;
    order.push_back(u);
    for(int v: edge[u]) dfs(v);
}

int b_search(int a, int b)
{
    if(a == b) return order[a];
    else
    {
        int m = (a+b)/2;
        vector<int> Q;
        for(int i = 0; i <= m; i++) Q.push_back(order[i]);

        if(query(Q)) return b_search(a, m);
        else return b_search(m+1, b);
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int e = 0; e < N-1; e++)
    {
        edge[ bridges[e].first ].push_back( bridges[e].second );
        edge[ bridges[e].second ].push_back( bridges[e].first );
    }

    dfs(1);

    return b_search(0, N-1);
}

Compilation message

eastereggs.cpp: In function 'void dfs(int)':
eastereggs.cpp:15:8: error: reference to 'visit' is ambiguous
   15 |     if(visit[u]) return;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from grader.h:1,
                 from eastereggs.cpp:3:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
eastereggs.cpp:11:13: note:                 'std::vector<int> visit'
   11 | vector<int> visit(1+maxN, 0);
      |             ^~~~~