제출 #1147949

#제출 시각아이디문제언어결과실행 시간메모리
1147949KodikRace (IOI11_race)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ss second #define ff first typedef long long ll; #define ll ll using pi = array<ll, 2>; const ll MOD = 1e9+7; ll n, k; const ll maxn = 2e5; vector<pair<ll,ll>> g[maxn]; ll sz[maxn]; pi node[maxn]; map<ll,ll> len_to_dep[maxn]; void dfs_sz(ll v, ll p, ll d, ll l){ sz[v] = 1; node[v] = {l, d}; for(auto &[w,u] : g[v]){ if(u!=p){ dfs_sz(u, v, d+1, l+w); sz[v] += sz[u]; } } } ll ans = 1e9; void dfs(ll v, ll p){ ll mx = -1, bigChild = -1; for(auto& [w, u] : g[v]){ if(u!=p&&sz[u]>mx){ mx = sz[u]; bigChild = u; } if(u!=p){ dfs(u, v); } } if(bigChild!=-1){ swap(len_to_dep[v], len_to_dep[bigChild]); } if(len_to_dep[v].count(node[v][0])>0) len_to_dep[v][node[v][0]] = min(len_to_dep[v][node[v][0]], node[v][1]); else len_to_dep[v][node[v][0]] = node[v][1]; for(auto &[w, u] : g[v]){ if(u!=p&&u!=bigChild){ for(auto &[l, d] : len_to_dep[u]){ ll seek = k-l+node[v][0]; if(len_to_dep[v].count(seek)>0){ ans = min(ans, d+len_to_dep[v][seek]-2*node[v][1]); } } for(auto &[l, d] : len_to_dep[u]){ if(len_to_dep[v].count(l)>0) len_to_dep[v][l] = min(len_to_dep[v][l], d); else len_to_dep[v][l] = d; } } } if(len_to_dep[v].count(k)>0) ans = min(ans, len_to_dep[v][k]); } int best_path(na, ka, h, l){ ios::sync_with_stdio(false); cin.tie(nullptr); n = na, k = ka; for(ll i = 0; i < n-1; ++i){ ll x; cin >> x; g[h[i][0]].push_back({x, h[i][1]}); g[h[i][1]].push_back({x, h[i][0]}); } dfs_sz(0,-1,0,0); dfs(0,-1); if(ans==1e9) ans = -1; cout << ans << '\n'; return 0; }

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

race.cpp:64:15: error: 'na' was not declared in this scope; did you mean 'nan'?
   64 | int best_path(na, ka, h, l){
      |               ^~
      |               nan
race.cpp:64:19: error: 'ka' was not declared in this scope; did you mean 'k'?
   64 | int best_path(na, ka, h, l){
      |                   ^~
      |                   k
race.cpp:64:23: error: 'h' was not declared in this scope
   64 | int best_path(na, ka, h, l){
      |                       ^
race.cpp:64:26: error: 'l' was not declared in this scope
   64 | int best_path(na, ka, h, l){
      |                          ^
race.cpp:64:27: error: expression list treated as compound expression in initializer [-fpermissive]
   64 | int best_path(na, ka, h, l){
      |                           ^