제출 #605488

#제출 시각아이디문제언어결과실행 시간메모리
605488mychecksedad경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include "race.h"

const int M = 2e5 + 100;

struct Edge{
    int next, len; 
};

int n, k, sub[M], best = M;
ll val[M];
vector<int> g[M];
map<int, pair<bool, int>> a[M];



void dfs(int v, int p){
    int mx = 0, big = -1;
    for(Edge e: g[v]){
        if(e.next != p && sub[e.next] > mx){
            mx = sub[e.next];
            big = e.next;
        }
    }
    for(Edge e: g[v]){
        if(e.next != p && e.next != big)
            dfs(u, v);
    }
    if(big > -1)
        dfs(big, v), a[v].swap(a[big]);
    
    if(a[v][val[v]].first == 0){
        a[v][val[v]].first = 1;
    }else a[v][val[v]].second = 0;

    for(Edge e: g[v]){
        if(e.next != big && e.next != p){
            for(auto p: a[e.next]){
                if(a[v][k - p.first + 2 * val[v]].first == 1) best = min(best, p.second.second + a[v][k - p.first + 2 * val[v]].second);
                 if(a[v][p.first].first == 0){
                    a[v][p.first] = {1, p.second.second};
                }else a[v][val[v]].second = min(a[v][val[v]].second, p.second.second);
            }
        }
    }
}


void init(int v, int p, ll d){
    sub[v] = 1;
    val[v] = d;
    for(Edge e: g[v]){
        if(e.next != p){
            dfs(e.next, v, d + e.len);
            sub[v] += sub[e.next];
        }
    }
}


int best_path(int N, int K, int H[][2], int L[])
{
    best = N;
    n = N;
    k = K;
    Edge e;
    for(int i = 0; i < n-1; ++i){
        e.next = H[i][1];
        e.len = L[i];
        g[H[i][0]].pb(e);
        e.next = H[i][0];
        g[H[i][1]].pb(e);
    }
    init(1, 0, 0);
    dfs(1, 0);

    return best;
}   

컴파일 시 표준 에러 (stderr) 메시지

race.cpp:10:1: error: 'll' does not name a type
   10 | ll val[M];
      | ^~
race.cpp:11:1: error: 'vector' does not name a type
   11 | vector<int> g[M];
      | ^~~~~~
race.cpp:12:1: error: 'map' does not name a type
   12 | map<int, pair<bool, int>> a[M];
      | ^~~
race.cpp: In function 'void dfs(int, int)':
race.cpp:18:17: error: 'g' was not declared in this scope
   18 |     for(Edge e: g[v]){
      |                 ^
race.cpp:24:17: error: 'g' was not declared in this scope
   24 |     for(Edge e: g[v]){
      |                 ^
race.cpp:26:17: error: 'u' was not declared in this scope
   26 |             dfs(u, v);
      |                 ^
race.cpp:29:22: error: 'a' was not declared in this scope
   29 |         dfs(big, v), a[v].swap(a[big]);
      |                      ^
race.cpp:31:8: error: 'a' was not declared in this scope
   31 |     if(a[v][val[v]].first == 0){
      |        ^
race.cpp:31:13: error: 'val' was not declared in this scope
   31 |     if(a[v][val[v]].first == 0){
      |             ^~~
race.cpp:35:17: error: 'g' was not declared in this scope
   35 |     for(Edge e: g[v]){
      |                 ^
race.cpp:37:25: error: 'a' was not declared in this scope
   37 |             for(auto p: a[e.next]){
      |                         ^
race.cpp:38:43: error: 'val' was not declared in this scope
   38 |                 if(a[v][k - p.first + 2 * val[v]].first == 1) best = min(best, p.second.second + a[v][k - p.first + 2 * val[v]].second);
      |                                           ^~~
race.cpp:38:70: error: 'min' was not declared in this scope
   38 |                 if(a[v][k - p.first + 2 * val[v]].first == 1) best = min(best, p.second.second + a[v][k - p.first + 2 * val[v]].second);
      |                                                                      ^~~
race.cpp:41:28: error: 'val' was not declared in this scope
   41 |                 }else a[v][val[v]].second = min(a[v][val[v]].second, p.second.second);
      |                            ^~~
race.cpp:41:45: error: 'min' was not declared in this scope
   41 |                 }else a[v][val[v]].second = min(a[v][val[v]].second, p.second.second);
      |                                             ^~~
race.cpp: At global scope:
race.cpp:48:25: error: 'll' has not been declared
   48 | void init(int v, int p, ll d){
      |                         ^~
race.cpp: In function 'void init(int, int, int)':
race.cpp:50:5: error: 'val' was not declared in this scope
   50 |     val[v] = d;
      |     ^~~
race.cpp:51:17: error: 'g' was not declared in this scope
   51 |     for(Edge e: g[v]){
      |                 ^
race.cpp:53:37: error: too many arguments to function 'void dfs(int, int)'
   53 |             dfs(e.next, v, d + e.len);
      |                                     ^
race.cpp:16:6: note: declared here
   16 | void dfs(int v, int p){
      |      ^~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:69:9: error: 'g' was not declared in this scope
   69 |         g[H[i][0]].pb(e);
      |         ^