# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867994 | TAhmed33 | Stranded Far From Home (BOI22_island) | C++98 | 598 ms | 524288 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>
using namespace std;
#define int long long
bool ok[200001];
vector <int> adj[200001];
int cnt[200001], sze[200001];
void dfs (int pos, int par) {
sze[pos] = cnt[pos];
for (auto j : adj[pos]) {
if (j != par) {
dfs(j, pos);
sze[pos] += sze[j];
}
}
}
void dfs2 (int pos, int par) {
if (par != -1) {
if (sze[pos] < cnt[par]) return;
}
ok[pos] = 1;
for (auto j : adj[pos]) if (j != par) dfs2(j, pos);
}
signed main () {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> cnt[i];
for (int i = 1; i < n; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |