# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758767 | keta_tsimakuridze | Pastiri (COI20_pastiri) | C++14 | 620 ms | 94744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
const int N = 5e5 + 5, mod = 1e9 + 7; // !
int n, d[N];
vector<int> V[N], A;
struct node {
int A, B, ans;
} x[N];
void dfs(int u, int p) {
for(int i = 0; i < V[u].size(); i++) {
int v = V[u][i];
if(v == p) continue;
dfs(v, u);
if(x[v].A + 1 > d[u]) {
x[v].ans++; A.push_back(v);
// cout << "++" << v << endl;
x[v].A = -n;
x[v].B = d[v];
}
x[u].A = max(x[u].A, x[v].A + 1);
x[u].B = max(x[u].B, x[v].B - 1);
x[u].ans += x[v].ans;
}
if(x[u].A <= x[u].B) x[u].A = -n - 5;
if(d[u] == 0 && x[u].B < 0) x[u].A = max(x[u].A, 0);
// cout << u <<" " << x[u].A << " " << x[u].B << " " << x[u].ans << endl;
Compilation message (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... |