제출 #298554

#제출 시각아이디문제언어결과실행 시간메모리
298554aloo123Traffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <ratio> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #include <climits> // #include "traffic.h" #define ll long long #define ld long double #define mp make_pair #define pb push_back #define in insert #define vll vector<ll> #define endl "\n" #define pll pair<ll,ll> #define f first #define s second #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++) // #define int ll #define sz(x) (ll)x.size() #define all(x) (x.begin(),x.end()) using namespace std; // const ll INF = 1e12; const int N =(1e6+5); // TODO : change value as per problem // const ll MOD = 1e9+7; vector<int> adj[N]; int sub[N]; int a[N]; void dfs(int u,int p){ sub[u] = a[u]; for(auto v:adj[u]){ if(v != p){ dfs(v,u); sub[u] += sub[v]; } } } int LocateCentre(int n,int p[],int s[],int d[]){ for(int i = 0;i<n;i++){ a[i+1] = p[i]; } for(int i =0;i<n-1;i++){ int u = s[i],v = d[i]; u++; v++; adj[u].pb(v); adj[v].pb(u); } int ans = INF,x = -1; for(int i = 1;i <= n;i++){ dfs(i,0); int ma = 0; for(auto v:adj[i]){ ma = max(ma,sub[v]); } if(ma < ans){ ans = ma; x = i; } } x--; return x; } // void solve(){ // } // signed main(){ // ios_base::sync_with_stdio(0); // cin.tie(NULL); // // freopen(".in","r",stdin);freopen(".out","w",stdout); // int n; // cin >> n; // int p[n]; // for(int i =0;i<n;i++){ // cin >> p[i]; // } // int s[n-1]; // int d[n-1]; // for(int i =0;i<n-1;i++){ // cin >> s[i] >> d[i]; // } // cout << LocateCentre(n,p,s,d) << endl; // }

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

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:77:15: error: 'INF' was not declared in this scope
   77 |     int ans = INF,x = -1;
      |               ^~~
traffic.cpp:86:13: error: 'x' was not declared in this scope
   86 |             x = i;
      |             ^
traffic.cpp:89:5: error: 'x' was not declared in this scope
   89 |     x--;
      |     ^