제출 #390927

#제출 시각아이디문제언어결과실행 시간메모리
390927SortingTraffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3; int n, *p, *s, *d, sz[N], sum_all = 0; vector<int> adj[N]; void dfs_solve(int u, int par = -1){ int sum = 0, mx = 0; for(int to: adj[u]) if(to != par){ dfs_solve(to, u); mx = max(mx, sz[to]); sum += sz[to]; } mx = max(mx, sum_all - sum - p[u]); ans = min(ans, mx); } void dfs_sz(int u, int par = -1){ sz[u] = p[u]; for(int to: adj[u]) if(to != par){ dfs_sz(to, u); sz[u] += sz[to]; } } int LocateCentre(int _n, int _p[], int _s[], int _d[]) { n = _n, p = _p, s = _s, d = _d; for(int i = 0; i < n; ++i) adj[i].clear(); for(int i = 0; i < n - 1; ++i){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } sum_all = 0, ans = INT_MAX; for(int i = 0; i < n; ++i) sum_all += p[i]; dfs_sz(0); dfs_solve(0); return ans; } /* 5 10 10 10 20 20 0 2 1 2 2 3 3 4 */

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

traffic.cpp: In function 'void dfs_solve(int, int)':
traffic.cpp:20:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |     ans = min(ans, mx);
      |     ^~~
      |     abs
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:40:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |     sum_all = 0, ans = INT_MAX;
      |                  ^~~
      |                  abs