제출 #790477

#제출 시각아이디문제언어결과실행 시간메모리
790477kilikuma경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #define pil pair<int,lld> #define pli pair<lld,int> #define pll pair<lld,lld> #define pii pair<int,int> #define pb push_back using namespace std; #define MAXN 200010 #define MAXK 1000010 vector<pii> adj[MAXN]; int N, K, siz[MAXN], res, b[MAXK]; bool vis[MAXN]; int dfsSize(int node, int prev) { siz[node] = 1; for(auto x : adj[node]) { if(x.fi != prev && !vis[x.fi]) siz[node] += dfsSize(x.fi, node); } return siz[node]; } int dfsCentroid(int node, int prev, int S) { for(auto x : adj[node]) { if(x.fi != prev && !vis[x.fi] && siz[x.fi] > S/2) return dfsCentroid(x.fi, node, S); } return node; } vector<int> v; vector<pii> vt; void dfsSolve(int node, int prev, int len, int dub) { vt.pb({dub, len}); v.pb(len); res = min(res, b[K-len]+dub); for(auto x : adj[node]) { if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1); } } void centroidDecomp(int node) { int S = dfsSize(node, node); node = dfsCentroid(node, node, S); vis[node] = 1; for(auto x : adj[node]) { if(!vis[x.fi] && x.se <= K) dfsSolve(x.fi, node, x.se, 1); for(auto y : vt) { b[y.se] = min(b[y.se], y.fi); } res = min(res, b[K]); vt.clear(); } for(auto x : v) b[x] = N; v.clear(); for(auto x : adj[node]) if(!vis[x.fi]) centroidDecomp(x.fi); } int best_path(int n, int k, int H[][2], int L[]) { N = n; K = k; for(int i = 0; i < N-1; i++) { adj[H[i][0]+1].pb({H[i][1]+1, L[i]}); adj[H[i][1]+1].pb({H[i][0]+1, L[i]}); } res = N; for(int i = 0; i <= K; i++) b[i] = N; centroidDecomp(1); return (res == N ? -1:res); }

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

race.cpp: In function 'int dfsSize(int, int)':
race.cpp:18:14: error: 'struct std::pair<int, int>' has no member named 'fi'
   18 |         if(x.fi != prev && !vis[x.fi]) siz[node] += dfsSize(x.fi, node);
      |              ^~
race.cpp:18:35: error: 'struct std::pair<int, int>' has no member named 'fi'
   18 |         if(x.fi != prev && !vis[x.fi]) siz[node] += dfsSize(x.fi, node);
      |                                   ^~
race.cpp:18:63: error: 'struct std::pair<int, int>' has no member named 'fi'
   18 |         if(x.fi != prev && !vis[x.fi]) siz[node] += dfsSize(x.fi, node);
      |                                                               ^~
race.cpp: In function 'int dfsCentroid(int, int, int)':
race.cpp:24:14: error: 'struct std::pair<int, int>' has no member named 'fi'
   24 |         if(x.fi != prev && !vis[x.fi] && siz[x.fi] > S/2) return dfsCentroid(x.fi, node, S);
      |              ^~
race.cpp:24:35: error: 'struct std::pair<int, int>' has no member named 'fi'
   24 |         if(x.fi != prev && !vis[x.fi] && siz[x.fi] > S/2) return dfsCentroid(x.fi, node, S);
      |                                   ^~
race.cpp:24:48: error: 'struct std::pair<int, int>' has no member named 'fi'
   24 |         if(x.fi != prev && !vis[x.fi] && siz[x.fi] > S/2) return dfsCentroid(x.fi, node, S);
      |                                                ^~
race.cpp:24:80: error: 'struct std::pair<int, int>' has no member named 'fi'
   24 |         if(x.fi != prev && !vis[x.fi] && siz[x.fi] > S/2) return dfsCentroid(x.fi, node, S);
      |                                                                                ^~
race.cpp: In function 'void dfsSolve(int, int, int, int)':
race.cpp:36:14: error: 'struct std::pair<int, int>' has no member named 'fi'
   36 |         if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1);
      |              ^~
race.cpp:36:35: error: 'struct std::pair<int, int>' has no member named 'fi'
   36 |         if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1);
      |                                   ^~
race.cpp:36:48: error: 'struct std::pair<int, int>' has no member named 'se'
   36 |         if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1);
      |                                                ^~
race.cpp:36:68: error: 'struct std::pair<int, int>' has no member named 'fi'
   36 |         if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1);
      |                                                                    ^~
race.cpp:36:84: error: 'struct std::pair<int, int>' has no member named 'se'
   36 |         if(x.fi != prev && !vis[x.fi] && len+x.se <= K) dfsSolve(x.fi, node, len+x.se, dub+1);
      |                                                                                    ^~
race.cpp: In function 'void centroidDecomp(int)':
race.cpp:45:19: error: 'struct std::pair<int, int>' has no member named 'fi'
   45 |         if(!vis[x.fi] && x.se <= K) dfsSolve(x.fi, node, x.se, 1);
      |                   ^~
race.cpp:45:28: error: 'struct std::pair<int, int>' has no member named 'se'
   45 |         if(!vis[x.fi] && x.se <= K) dfsSolve(x.fi, node, x.se, 1);
      |                            ^~
race.cpp:45:48: error: 'struct std::pair<int, int>' has no member named 'fi'
   45 |         if(!vis[x.fi] && x.se <= K) dfsSolve(x.fi, node, x.se, 1);
      |                                                ^~
race.cpp:45:60: error: 'struct std::pair<int, int>' has no member named 'se'
   45 |         if(!vis[x.fi] && x.se <= K) dfsSolve(x.fi, node, x.se, 1);
      |                                                            ^~
race.cpp:47:17: error: 'struct std::pair<int, int>' has no member named 'se'
   47 |             b[y.se] = min(b[y.se], y.fi);
      |                 ^~
race.cpp:47:31: error: 'struct std::pair<int, int>' has no member named 'se'
   47 |             b[y.se] = min(b[y.se], y.fi);
      |                               ^~
race.cpp:47:38: error: 'struct std::pair<int, int>' has no member named 'fi'
   47 |             b[y.se] = min(b[y.se], y.fi);
      |                                      ^~
race.cpp:54:39: error: 'struct std::pair<int, int>' has no member named 'fi'
   54 |     for(auto x : adj[node]) if(!vis[x.fi]) centroidDecomp(x.fi);
      |                                       ^~
race.cpp:54:61: error: 'struct std::pair<int, int>' has no member named 'fi'
   54 |     for(auto x : adj[node]) if(!vis[x.fi]) centroidDecomp(x.fi);
      |                                                             ^~