제출 #362843

#제출 시각아이디문제언어결과실행 시간메모리
362843David_M경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include<bits/stdc++.h> using namespace std; const int N=200005; int sz[N], e[N], z1[N], z2[N], o; vector <pair<int, int> > v[N]; map<int, int> m[N]; void solve(int x=0, int pa=0){ sz[x]=1; int mx=0, Y, D; for (auto [y,d]:v[x]){ if(y==pa)continue; solve(y); sz[x]+=sz[y]; if(sz[y]>mx) mx=sz[y], Y=y, D=d; } if(sz[x]==1) e[x]=o++; else z1[x]=z1[Y]+D, z2[x]=z2[Y]+1, e[x]=e[Y]; for (auto [y,d]:v[x]){ if(y==pa||y==Y)continue; for(auto [k,ans]:m[e[y]]){ k += d+z1[y]+z1[x]; ans+=1+z2[y]+z2[x]; if(m[e[x]].find(K-k)!=m[e[x]].end()) Ans=min(Ans, ans+m[e[x]][K-k]); } for(auto [k,ans]:m[e[y]]){ k += d+z1[y]-z1[x]; ans+=1+z2[y]-z1[x]; if(m[e[x]].find(k)==m[e[x]].end() || m[e[x]][k]>ans) m[e[x]][k]=ans; } } if(m[e[x]].find(K-z1[x])!=m[e[x]].end())Ans=min(Ans,z2[x]+m[e[x]][K-z1[x]]); } int best_path(int N, int K, int H[][2], int L[]){ for (int i=0; i<N-1; i++) v[H[i][0]].push_back({H[i][1],L[i]}), v[H[i][1]].push_back({H[i][0],L[i]}); solve(); return Ans; }

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

race.cpp: In function 'void solve(int, int)':
race.cpp:15:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |  for (auto [y,d]:v[x]){
      |            ^
race.cpp:25:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |  for (auto [y,d]:v[x]){
      |            ^
race.cpp:27:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |   for(auto [k,ans]:m[e[y]]){
      |            ^
race.cpp:28:6: error: assignment of read-only reference 'k'
   28 |    k += d+z1[y]+z1[x];
      |    ~~^~~~~~~~~~~~~~~~
race.cpp:30:20: error: 'K' was not declared in this scope
   30 |    if(m[e[x]].find(K-k)!=m[e[x]].end()) Ans=min(Ans, ans+m[e[x]][K-k]);
      |                    ^
race.cpp:30:41: error: 'Ans' was not declared in this scope; did you mean 'ans'?
   30 |    if(m[e[x]].find(K-k)!=m[e[x]].end()) Ans=min(Ans, ans+m[e[x]][K-k]);
      |                                         ^~~
      |                                         ans
race.cpp:32:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |   for(auto [k,ans]:m[e[y]]){
      |            ^
race.cpp:33:6: error: assignment of read-only reference 'k'
   33 |    k += d+z1[y]-z1[x];
      |    ~~^~~~~~~~~~~~~~~~
race.cpp:38:18: error: 'K' was not declared in this scope
   38 |  if(m[e[x]].find(K-z1[x])!=m[e[x]].end())Ans=min(Ans,z2[x]+m[e[x]][K-z1[x]]);
      |                  ^
race.cpp:38:42: error: 'Ans' was not declared in this scope
   38 |  if(m[e[x]].find(K-z1[x])!=m[e[x]].end())Ans=min(Ans,z2[x]+m[e[x]][K-z1[x]]);
      |                                          ^~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:49:9: error: 'Ans' was not declared in this scope
   49 |  return Ans;
      |         ^~~