제출 #694519

#제출 시각아이디문제언어결과실행 시간메모리
694519ac2hu경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MX = 2e5 + 10; const int LAR = 1e7 + 10; int n, k, ans = 1e9, timer = 0, tin[MX], tout[MX], rev[MX], d[MX], ed[MX], siz[MX], bigc[MX]; vector<pair<int,int>> adj[MX]; map<int, int> mnedge; void dfs2(int v,int p, bool keep){// keep for(auto [e, w] : adj[v]){ if(p != e && bigc[v] != e)dfs2(e, v, false); } if(bigc[v] != -1)dfs2(bigc[v], v, true); if(mnedge.find(d[v] + k) != mnedge.end())ans = min(ans, mnedge[d[v] + k] - ed[v]); mnedge[d[v]] = ed[v]; for(int [e, w] : adj[v]){ if(e == p || e == bigc[v])continue; for(int st = tin[e];st<=tout[e];st++){ int node = rev[st]; // d[node] + d[x] - 2*d[v] = k => d[x] = k + 2*d[v] - d[node] int c = k + 2*d[v]] - d[node]; if(mnedge.find(c) != mnedge.end())ans = min(ans, mnedge[c] + ed[node] - 2*ed[v]); } for(int st = tin[e];st<=tout[e];st++){ mnedge[d[rev[st]]] = ed[rev[st]]; } } if(!keep){ mnedge.erase(d[v]); for(int [e, w] : adj[v]){ if(e == p)continue; for(int st = tin[e];st<=tout[e];st++){ mnedge.erase(d[rev[st]]); } } } void dfs1(int v,int p){ int mx = -1; rev[timer] = v; tin[v] = timer++; bigc[v] = -1; siz[v] = 1; for(auto [e, w] : adj[v]){ if(e == p)continue; d[e] = d[v] + w; ed[e] = ed[v] + 1; dfs2(e, v); if(siz[e] > mx){ bigc[v] = e; siz[v] += siz[e]; mx = siz[e]; } } tout[v] = timer; } int best(int N, int K, int H[][2], int L[]){ n = N, k = K; for(int i = 0;i + 1<n;i++){ int a = H[i][0], b = H[i][1], c = L[i]; adj[a].push_back({b, c}); adj[b].push_back({a, c}); } dfs1(0, -1); dfs2(0, -1, true); return ans; } // signed main() { // iostream::sync_with_stdio(0);cin.tie(0); // }

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

race.cpp: In function 'void dfs2(int, int, bool)':
race.cpp:9:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
    9 |     for(auto [e, w] : adj[v]){
      |              ^
race.cpp:15:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(int [e, w] : adj[v]){
      |             ^
race.cpp:15:13: error: structured binding declaration cannot have type 'int'
   15 |     for(int [e, w] : adj[v]){
      |             ^~~~~~
race.cpp:15:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
race.cpp:20:31: error: expected ',' or ';' before ']' token
   20 |             int c = k + 2*d[v]] - d[node];
      |                               ^
race.cpp:29:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         for(int [e, w] : adj[v]){
      |                 ^
race.cpp:29:17: error: structured binding declaration cannot have type 'int'
   29 |         for(int [e, w] : adj[v]){
      |                 ^~~~~~
race.cpp:29:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
race.cpp:36:23: error: a function-definition is not allowed here before '{' token
   36 | void dfs1(int v,int p){
      |                       ^
race.cpp:55:44: error: a function-definition is not allowed here before '{' token
   55 | int best(int N, int K, int H[][2], int L[]){
      |                                            ^
race.cpp:65:1: error: expected '}' at end of input
   65 | }
      | ^
race.cpp:8:34: note: to match this '{'
    8 | void dfs2(int v,int p, bool keep){// keep
      |                                  ^