# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345550 | 79brue | 꿈 (IOI13_dreaming) | C++14 | 0 ms | 0 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;
typedef long long ll;
int n, m, k;
vector<pair<int, int> > link[100002];
int DP[100002], DP2[100002];
bool visited[100002];
int ans;
int minVal;
vector<int> vec;
void dfs(int x){
visited[x] = 1;
for(auto y: link[x]){
if(visited[y.first]) continue;
dfs(y.first);
int tmp1 = DP[y.first] + y.second;
int tmp2 = DP2[y.first] + y.second;
if(DP2[x] < tmp1) DP2[x] = tmp1;
if(DP2[x] > DP[x]) swap(DP[x], DP2[x]);
if(DP2[x] < tmp2) DP2[x] = tmp2;
}
if(DP[x] < 0) DP[x] = 0;
ans = max(ans, DP[x] + DP2[x]);
visited[x] = 0;