제출 #363801

#제출 시각아이디문제언어결과실행 시간메모리
363801David_M경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); struct chash { int operator()(int x) const { return x ^ RANDOM; } }; const int N=200005; int sz[N], e[N], z1[N], z2[N], o, k, K, Ans=N; vector <pair<int, int> > v[N]; gp_hash_table<int, int, chash> 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, x); 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]; m[e[x]][0-z1[x]]=0-z2[x]; for (auto [y,d]:v[x]){ if(y==pa||y==Y)continue; for(auto [kk,ans]:m[e[y]]){ k=kk+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 [kk,ans]:m[e[y]]){ k=kk+d+z1[y]-z1[x]; ans+=1+z2[y]-z2[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[]){ K=k; 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==N)?-1:Ans; }

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

race.cpp:12:1: error: 'gp_hash_table' does not name a type
   12 | gp_hash_table<int, int, chash> m[N];
      | ^~~~~~~~~~~~~
race.cpp: In function 'void solve(int, int)':
race.cpp:19:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |  for (auto [y,d]:v[x]){
      |            ^
race.cpp:28:2: error: 'm' was not declared in this scope
   28 |  m[e[x]][0-z1[x]]=0-z2[x];
      |  ^
race.cpp:30:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |  for (auto [y,d]:v[x]){
      |            ^
race.cpp:32:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |   for(auto [kk,ans]:m[e[y]]){
      |            ^
race.cpp:37:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |   for(auto [kk,ans]:m[e[y]]){
      |            ^