제출 #395600

#제출 시각아이디문제언어결과실행 시간메모리
395600garnab27Traffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll int64_t using namespace std; vector<ll > sum; vector<ll > ans; vector<int> g[1000006]; ll dfs1(int u, int p) { sum[u] += P[u]; for(int v: g[u]) { if(v != p) { sum[u] += dfs1(v, u); } } return sum[u]; } void dfs2(int u, int p, ll psum) { ans[u] = 0; ll csum = P[u]; if(p != -1) { ans[u] = max(ans[u], psum); csum += psum; } for(int v: g[u]) { if(v != p) { csum += sum[v]; ans[u] = max(ans[u], sum[v]); } } for(int v: g[u]) { if(v != p) { dfs2(v, u, csum - sum[v]); } } } int LocateCentre(int N, int pp[], int S[], int D[]) { sum.resize(N); ans.resize(N); for(int i=0;i<N-1;i++) { g[S[i]].pb(D[i]); g[D[i]].pb(S[i]); } dfs1(0, -1); dfs2(0, -1, 0); int id = 0, mn = ans[0]; for(int i=1;i<N;i++) { if(mn > ans[i]) { mn = ans[i]; id = i; } } return id; }

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

traffic.cpp: In function 'int64_t dfs1(int, int)':
traffic.cpp:10:12: error: 'P' was not declared in this scope
   10 |  sum[u] += P[u];
      |            ^
traffic.cpp: In function 'void dfs2(int, int, int64_t)':
traffic.cpp:24:12: error: 'P' was not declared in this scope
   24 |  ll csum = P[u];
      |            ^
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:47:14: error: 'class std::vector<int>' has no member named 'pb'
   47 |      g[S[i]].pb(D[i]);
      |              ^~
traffic.cpp:48:14: error: 'class std::vector<int>' has no member named 'pb'
   48 |      g[D[i]].pb(S[i]);
      |              ^~