Submission #532229

#TimeUsernameProblemLanguageResultExecution timeMemory
532229srivatsav_kannanTraffic (IOI10_traffic)C++14
50 / 100
15 ms2508 KiB
#include <iostream> #include "traffic.h" #include <fstream> #include <vector> #include <set> #include <queue> #include <cmath> #include <map> #include <algorithm> #include <numeric> #include <stack> #include <cstring> #include <bitset> #include <climits> #include <valarray> #include <list> #define INF 1000000000 #define endl '\n' #define mod 1000000007 using namespace std; vector<int> adj[1000]; int vis[1000], ar[1000]; int dfs(int node, bool root = true){ int mx = 0; if (!root) mx = ar[node]; vis[node] = 1; for (int child:adj[node]){ if (vis[child] == 0){ int cur = dfs(child, false); if (root) mx = max(mx, cur); else mx += cur; } } return mx; } int LocateCentre(int n, int p[], int s[], int d[]){ for (int i = 0; i < n-1; i++){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } for (int i = 0; i < n; i++) ar[i] = p[i]; int mn = 1e17, mni = -1; for (int i = 0; i < n; i++){ memset(vis, 0, sizeof vis); int cur = dfs(i); if (cur < mn){ mn = cur; mni = i; } } return mni; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:43:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
   43 |     int mn = 1e17, mni = -1;
      |              ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...