제출 #373531

#제출 시각아이디문제언어결과실행 시간메모리
373531lakshith_Traffic (IOI10_traffic)C++14
0 / 100
16 ms23788 KiB
#include <bits/stdc++.h> #include "traffic.h" #define pb push_back #define ll int using namespace std; vector<vector<int>> adj(1000000,vector<int>()); map<pair<int,int>,ll> m; ll dp(int p,int c,int* P){ if(m.find((pair<int,int>){p,c})!=m.end())return m[(pair<int,int>){p,c}]; ll ans = P[c]; for(int v:adj[c]){ if(v==p)continue; ans += dp(c,v,P); } m.insert({{p,c},ans}); return ans; } int LocateCentre(int n,int p[],int s[],int d[]){ for(int i=0;i<n-1;i++){ adj.at(s[i]).pb(d[i]); adj.at(d[i]).pb(s[i]); } ll ans = LLONG_MAX; int index = -1; for(int i=0;i<n;i++){ ll local = LLONG_MIN; for(int v:adj[i])local = max(local,dp(i,v,p)); if(local<ans){ ans = local; index = i; } } return index; }

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

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:28:16: warning: overflow in conversion from 'long long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   28 |       ll ans = LLONG_MAX;
      |                ^~~~~~~~~
traffic.cpp:31:22: warning: overflow in conversion from 'long long int' to 'int' changes value from '-9223372036854775808' to '0' [-Woverflow]
   31 |           ll local = LLONG_MIN;
      |                      ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...