# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
345550 | 79brue | 꿈 (IOI13_dreaming) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;