# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
618218 | penguinhacker | Power Plant (JOI20_power) | C++17 | 148 ms | 28896 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 ll long long
#define ar array
const int mxN=2e5;
int n, ans, dp[mxN];
string s;
vector<int> adj[mxN];
void dfs(int u=0, int p=-1) {
int mx=0;
dp[u]='0'-s[u];
for (int v : adj[u])
if (v!=p) {
dfs(v, u);
dp[u]+=max(dp[v], 0);
mx=max(mx, dp[v]);
}
ans=max(ans, mx+(s[u]=='1'));
if (s[u]=='1')
dp[u]=max(dp[u], 1);
ans=max(ans, dp[u]);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |