Submission #671956

#TimeUsernameProblemLanguageResultExecution timeMemory
671956sudheerays123Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll int const ll N = 1000+5 , INF = 1e18 , MOD = 1e9+7; vector<ll> adj[N+5]; vector<ll> pop(N+5) , sub(N+5); ll dfs(ll s , ll p , int p[]){ ll ans = -INF; for(auto u : adj[s]){ if(u == p) continue; dfs(u,s); ans = max(ans,sub[u]+p[u]); sub[s] += sub[u]+p[u]; } return ans; } int LocateCentre(int n, int p[], int S[], int D[]){ for(ll i = 0; i < n-1; i++){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } ll ans = INF , city; for(ll i = 0; i < n; i++){ for(ll j = 0; j < n; j++) sub[j] = 0; ll x = dfs(i,0,p); if(x < ans){ ans = x; city = i; } } cout << city; }

Compilation message (stderr)

traffic.cpp:7:29: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    7 | const ll N = 1000+5 , INF = 1e18 , MOD = 1e9+7;
      |                             ^~~~
traffic.cpp:12:26: error: conflicting declaration 'int* p'
   12 | ll dfs(ll s , ll p , int p[]){
      |                      ~~~~^~~
traffic.cpp:12:18: note: previous declaration as 'int p'
   12 | ll dfs(ll s , ll p , int p[]){
      |                  ^
traffic.cpp: In function 'int dfs(int, int)':
traffic.cpp:19:25: error: invalid types 'int[int]' for array subscript
   19 |   ans = max(ans,sub[u]+p[u]);
      |                         ^
traffic.cpp:20:21: error: invalid types 'int[int]' for array subscript
   20 |   sub[s] += sub[u]+p[u];
      |                     ^
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:29:7: error: 's' was not declared in this scope
   29 |   adj[s[i]].push_back(d[i]);
      |       ^
traffic.cpp:29:23: error: 'd' was not declared in this scope
   29 |   adj[s[i]].push_back(d[i]);
      |                       ^
traffic.cpp:37:19: error: too many arguments to function 'int dfs(int, int)'
   37 |   ll x = dfs(i,0,p);
      |                   ^
traffic.cpp:12:4: note: declared here
   12 | ll dfs(ll s , ll p , int p[]){
      |    ^~~
traffic.cpp:45:1: warning: no return statement in function returning non-void [-Wreturn-type]
   45 | }
      | ^