Submission #1272483

#TimeUsernameProblemLanguageResultExecution timeMemory
1272483dangheoRace (IOI11_race)C++20
Compilation error
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 <unordered_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);
}

Compilation message (stderr)

race.cpp: In function 'void dfs(int)':
race.cpp:34:5: error: 'map' was not declared in this scope
   34 |     map <ll, int> &cur = dist[i];
      |     ^~~
race.cpp:14:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
   13 | #include "race.h"
  +++ |+#include <map>
   14 | 
race.cpp:34:12: error: expected primary-expression before ',' token
   34 |     map <ll, int> &cur = dist[i];
      |            ^
race.cpp:34:14: error: expected primary-expression before 'int'
   34 |     map <ll, int> &cur = dist[i];
      |              ^~~
race.cpp:35:5: error: 'cur' was not declared in this scope
   35 |     cur.emplace(d[i], h[i]);
      |     ^~~