제출 #1272481

#제출 시각아이디문제언어결과실행 시간메모리
1272481dangheo경주 (Race) (IOI11_race)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
#include "race.h"

#define hyathu main
#define popcorn __builtin_popcount

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

constexpr int mmb = 1e5 + 69;
const ld pi = atan(1) * 4;

vector <pair <int, ll>> v[mmb];
int p[mmb];
unordered_map <ll, int> dist[mmb];
ll d[mmb], K;
int h[mmb];
int ans = 2e9;

void dfs(int i){
    map <ll, int> &cur = dist[i];
    cur.emplace(d[i], h[i]);
    
    for(pair <int, ll> &adj : v[i]){
        int nx = adj.first;
        ll ad = adj.second;
        if(nx == p[i]) continue;
        
        p[nx] = i;
        d[nx] = d[i] + ad;
        h[nx] = h[i] + 1;
        dfs(nx);
        
        for(pair <const ll, int> &dst : dist[nx]){
            ll ds = dst.first;
            int hs = dst.second;
            auto it = cur.find(K - ds + 2 * d[i]);
            if(it != cur.end())
                ans = min(ans, hs + it->second - 2 * h[i]);
        }
        
        for(pair <const ll, int> &dst : dist[nx]){
            ll ds = dst.first;
            int hs = dst.second;
            auto res = cur.insert(dst);
            if(!res.second) res.first->second = min(res.first->second, hs);
        }
        
        dist[nx].clear();
    }
}

int best_path(int n, int k, int h[][2], int l[]){
    fill(p, p + n, -1);
    
    K = k;
    for(int i = 0; i < n - 1; ++i){
        v[h[i][0]].emplace_back(h[i][1], l[i]);
        v[h[i][1]].emplace_back(h[i][0], l[i]);
    }
    
    dfs(0);
    return (ans == 2e9 ? -1 : ans);
}

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

race.cpp:28:1: error: 'unordered_map' does not name a type
   28 | unordered_map <ll, int> dist[mmb];
      | ^~~~~~~~~~~~~
race.cpp: In function 'void dfs(int)':
race.cpp:34:26: error: 'dist' was not declared in this scope
   34 |     map <ll, int> &cur = dist[i];
      |                          ^~~~