제출 #775591

#제출 시각아이디문제언어결과실행 시간메모리
775591DobromirAngelovTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "traffic.h" using namespace std; const int MAXN=1e6+5; const int INF=2e9+5; int a[MAXN]; vector<int> adj[MAXN]; int subtr[MAXN]; int dfs(int v,int par) { subtr[v]=a[v]; for(int i=0;i<adj[v].size();i++) { if(adj[v][i]==par) continue; subtr[v]+=dfs(adj[v][i], v); } return subtr[v]; } void LocateCentre(int n,int w[],int u[],int v[]) { for(int i=0;i<n;i++) { a[i]=w[i]; adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,-1); int ans=-1, best=INF; for(int i=0;i<n;i++) { int curMax=subtr[0]-subtr[i]; for(int j=0;j<adj[i].size();j++) { curMax=max(curMax, subtr[adj[i][j]]); } if(curMax<best) { best=curMax; ans=i; } } return ans; }

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

traffic.cpp: In function 'int dfs(int, int)':
traffic.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<adj[v].size();i++)
      |                 ~^~~~~~~~~~~~~~
traffic.cpp: At global scope:
traffic.cpp:24:6: error: ambiguating new declaration of 'void LocateCentre(int, int*, int*, int*)'
   24 | void LocateCentre(int n,int w[],int u[],int v[])
      |      ^~~~~~~~~~~~
In file included from traffic.cpp:2:
traffic.h:1:5: note: old declaration 'int LocateCentre(int, int*, int*, int*)'
    1 | int LocateCentre(int N, int P[], int S[], int D[]);
      |     ^~~~~~~~~~~~
traffic.cpp: In function 'void LocateCentre(int, int*, int*, int*)':
traffic.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j=0;j<adj[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
traffic.cpp:50:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   50 |     return ans;
      |            ^~~