답안 #384466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384466 2021-04-01T17:38:01 Z ak2006 Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.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:3:12: error: 'vector' does not name a type
    3 | using vi = vector<int>;
      |            ^~~~~~
eastereggs.cpp:4:13: error: 'vector' does not name a type
    4 | using vvi = vector<vi>;
      |             ^~~~~~
eastereggs.cpp:5:1: error: 'vvi' does not name a type
    5 | vvi adj(513);
      | ^~~
eastereggs.cpp:6:1: error: 'vi' does not name a type
    6 | vi a;
      | ^~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:9:5: error: 'a' was not declared in this scope
    9 |     a.pb(i);
      |     ^
eastereggs.cpp:10:16: error: 'adj' was not declared in this scope
   10 |     for (int c:adj[i]){
      |                ^~~
eastereggs.cpp: At global scope:
eastereggs.cpp:15:19: error: 'vector' has not been declared
   15 | int findEgg(int n,vector<pair<int,int>>b)
      |                   ^~~~~~
eastereggs.cpp:15:25: error: expected ',' or '...' before '<' token
   15 | int findEgg(int n,vector<pair<int,int>>b)
      |                         ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:17:31: error: 'adj' was not declared in this scope
   17 |     for (int i = 0;i<=512;i++)adj[i].clear();
      |                               ^~~
eastereggs.cpp:18:5: error: 'a' was not declared in this scope
   18 |     a.clear();
      |     ^
eastereggs.cpp:19:32: error: 'adj' was not declared in this scope
   19 |     for (int i = 0;i<n - 1;i++)adj[b[i].first].pb(b[i].second);
      |                                ^~~
eastereggs.cpp:19:36: error: 'b' was not declared in this scope
   19 |     for (int i = 0;i<n - 1;i++)adj[b[i].first].pb(b[i].second);
      |                                    ^
eastereggs.cpp:24:19: error: 'vi' was not declared in this scope
   24 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |                   ^~
eastereggs.cpp:24:50: error: expected primary-expression before ')' token
   24 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |                                                  ^
eastereggs.cpp:24:13: error: 'query' was not declared in this scope
   24 |         if (query(vi<(a.begin(),a.begin() + mid)>)){
      |             ^~~~~