답안 #384467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384467 2021-04-01T17:38:53 Z ak2006 Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
    a.pb(i);
    for (int c:adj[i]){
        if (c == p)continue;
        dfs(c,i);
    }
}
int findEgg(int n,vector<pair<int,int>>b)
{
    for (int i = 0;i<=512;i++)adj[i].clear();
    a.clear();
    for (int i = 0;i<n - 1;i++)adj[b[i].first].pb(b[i].second);
    dfs(1,1);
    int l = 0,r = n - 1,ans = 1;
    while (l <= r){
        int mid = (l + r)/2;
        if (query(vi<(a.begin(),a.begin() + mid)>)){
            r = mid - 1;
        }
        else l = mid + 1,ans = mid + 1;
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:25:19: error: 'vi' {aka 'std::vector<int>'} is not a template
   25 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |                   ^~
eastereggs.cpp:25:31: error: call to non-'constexpr' function 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::begin() [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*]'
   25 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |                               ^
eastereggs.cpp:25:50: error: expected primary-expression before ')' token
   25 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |                                                  ^