제출 #877894

#제출 시각아이디문제언어결과실행 시간메모리
877894raul2008487경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "race.h" #define ll long long #define pb push_back #define eb emplace_back #define vl vector<ll> #define fi first #define se second #define in insert #define mpr make_pair #define lg(x) __lg(x) #define bpc(x) __builtin_popcount(x) #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 2e5+5; const ll inf = 1000000000000000; bool used[sz]; vector<pair<ll,ll>> ajd[sz]; vl arr; ll n, k, ss[sz], res = inf; map<ll,ll> mp; void construct(ll node, ll p){ ss[node] = 1; for(pair<ll,ll> edge: adj[node]){ if(!used[edge.fi] && edge.fi != p){ construct(edge.fi, node); ss[node] += ss[edge.fi]; } } } ll centroid(ll v, ll p, ll cs){ for(pair<ll,ll> edge: adj[v]){ if(edge.fi == p || used[edge.fi]){continue;} if(ss[edge.fi] > (cs>>1)){ return centroid(edge.fi, v, cs); } } return v; } void init(ll v, ll p, ll w, ll we){ if(mp.find(k - w) != mp.end()){ res = min(res, mp[k-w] + we); } arr.eb({w, we}); for(pair<ll,ll> edge: adj[v]){ if(used[v] || edge.fi == p){continue;} init(edge.fi, v, w + edge.se, we + 1); } } void calc(ll node){ mp.clear(); construct(node, -1); ll c = centroid(node, -1, ss[node]); mp[0] = 0; for(pair<ll,ll> edge: adj[c]){ if(used[edge.fi]){continue;} arr.clear(); init(edge.fi, c, edge.se, 1); for(pair<ll,ll> y: arr){ if(mp.find(y.fi) == mp.end()){ mp[y.fi] = y.se; } else{ mp[y.fi] = min(mp[y.fi], y.se); } } } used[c] = 1; for(pair<ll,ll> edge: adj[c]){ if(!used[edge.fi]){ calc(edge.fi); } } } int best_path(int N, int K, int H[][2], int L[]) { n = N; k = K; for(i=0;i<n-1;i++){ adj[H[i][0]].pb({H[i][1], L[i]}); adj[H[i][1]].pb({H[i][0], L[i]}); } calc(0); if(res == inf){ return -1 } return res; }

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

race.cpp: In function 'void construct(long long int, long long int)':
race.cpp:25:27: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   25 |     for(pair<ll,ll> edge: adj[node]){
      |                           ^~~
      |                           ajd
race.cpp: In function 'long long int centroid(long long int, long long int, long long int)':
race.cpp:33:27: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   33 |     for(pair<ll,ll> edge: adj[v]){
      |                           ^~~
      |                           ajd
race.cpp: In function 'void init(long long int, long long int, long long int, long long int)':
race.cpp:45:19: error: no matching function for call to 'std::vector<long long int>::emplace_back(<brace-enclosed initializer list>)'
   45 |     arr.eb({w, we});
      |                   ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/10/bits/vector.tcc:109:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {}; _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::reference = long long int&]'
  109 |       vector<_Tp, _Alloc>::
      |       ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:109:7: note:   candidate expects 0 arguments, 1 provided
race.cpp:46:27: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   46 |     for(pair<ll,ll> edge: adj[v]){
      |                           ^~~
      |                           ajd
race.cpp: In function 'void calc(long long int)':
race.cpp:56:27: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   56 |     for(pair<ll,ll> edge: adj[c]){
      |                           ^~~
      |                           ajd
race.cpp:60:28: error: conversion from 'long long int' to non-scalar type 'std::pair<long long int, long long int>' requested
   60 |         for(pair<ll,ll> y: arr){
      |                            ^~~
race.cpp:70:27: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   70 |     for(pair<ll,ll> edge: adj[c]){
      |                           ^~~
      |                           ajd
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:80:9: error: 'i' was not declared in this scope
   80 |     for(i=0;i<n-1;i++){
      |         ^
race.cpp:81:9: error: 'adj' was not declared in this scope; did you mean 'ajd'?
   81 |         adj[H[i][0]].pb({H[i][1], L[i]});
      |         ^~~
      |         ajd
race.cpp:86:18: error: expected ';' before '}' token
   86 |         return -1
      |                  ^
      |                  ;
   87 |     }
      |     ~