(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #283397

#TimeUsernameProblemLanguageResultExecution timeMemory
283397kevleeTraffic (IOI10_traffic)C++17
100 / 100
1284 ms152728 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mod 1000000007 #define h1 7897897897897897 #define h2 7897466719774591 #define b1 98762051 #define b2 98765431 #define inf 1000000000 #define pi 3.1415926535897932384626 #define LMAX 9223372036854775807 #define ll long long #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pii> #define SET(a, b) memset(a, b, sizeof(a)); #define all(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) int a[1000005], v[1000005], sum; vi edges[1000005]; int dfs(int x, int p) { int children = 0; for (auto y: edges[x]) { if (y == p) continue; int t = dfs(y, x); children += t; a[x] = max(a[x], t); } a[x] = max(a[x], sum - children - v[x]); return children + v[x]; } int LocateCentre(int n, int P[], int s[], int d[]) { FOR(i, 0, n-1) { v[i] = P[i]; sum += v[i]; } FOR(i, 0, n-2) { edges[s[i]].pb(d[i]); edges[d[i]].pb(s[i]); } int useless = dfs(0, -1), minn = INT_MAX, ans = 0; FOR(i, 0, n-1) { if (a[i] < minn) { minn = a[i]; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:47:7: warning: unused variable 'useless' [-Wunused-variable]
   47 |   int useless = dfs(0, -1), minn = INT_MAX, ans = 0;
      |       ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...