# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
640172 | colossal_pepe | Power Plant (JOI20_power) | C++17 | 548 ms | 62496 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 <iostream>
#include <vector>
#include <map>
using namespace std;
int n;
vector<vector<int>> g;
string s;
vector<map<int, int>> dp;
vector<int> dp_sum;
int f(int a, int b) {
return (s[a] == '1' ? max(1, dp_sum[a] - dp[a][b] - 1) : dp_sum[a] - dp[a][b]);
}
int dfs1(int u, int par) {
dp[u][par] = 0;
for (int v : g[u]) {
if (v != par) {
dp[u][v] = dfs1(v, u);
dp_sum[u] += dp[u][v];
}
}
return f(u, par);
}
void dfs2(int u, int par) {
dp[u][par] = f(par, u);
dp_sum[u] += dp[u][par];
for (int v : g[u]) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |