# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1123634 | marinaluca | Traffic (IOI10_traffic) | C++20 | 16 ms | 23876 KiB |
#include <bits/stdc++.h>
#include "traffic.h"
#pragma GCC optimize ("O3")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
using namespace std;
//#define int long long
#define ll long long
#define all (x) begin(x), end(x)
#define xx first
#define yy second
using pii = pair <int, int>;
using tii = tuple <int, int, int>;
constexpr int NMAX = (int) 1e6;
vector <int> ans[NMAX + 1];
ll lazy[NMAX + 1];
ll cp[NMAX + 1];
ll s, maxi;
int rez;
inline void dfs (int nod, int parent)
{
ll maxi = 0;
for (auto elem : ans[nod])
{
if (elem == parent)
continue;
dfs (elem, nod);
lazy[nod] += lazy[elem];
maxi = max (maxi, lazy[elem]);
}
cp[nod] = maxi;
}
int LocateCentre(int n,int p[],int S[],int D[])
{
maxi = 1e19;
rez = -1;
for (int i = 0; i < n; ++ i)
{
lazy[i] = p[i];
s += lazy[i];
}
for (int i = 0; i < n - 1; ++ i)
{
ans[S[i]].push_back(S[i]);
ans[D[i]].push_back(D[i]);
}
dfs (0, -1);
for (int i = 0; i < n; ++ i)
{
cp[i] = max (cp[i], s - lazy[i]);
if (cp[i] < maxi)
{
maxi = cp[i];
rez = i;
}
}
return rez;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |