제출 #1183119

#제출 시각아이디문제언어결과실행 시간메모리
1183119burgerguyFriend (IOI14_friend)C++20
35 / 100
0 ms328 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; using ll = long long; int findSample(int n, int conf[], int host[], int p[]) { vector<ll> choose(n), notChoose(n); for (int i = 0; i < n; ++i) { choose[i] = conf[i]; notChoose[i] = 0; } for (int i = n - 1; i > 0; --i) { ll hostNode = host[i]; ll newNode = i; if(p[i] == 0) { choose[hostNode] = choose[hostNode] + notChoose[newNode]; notChoose[hostNode] = max(notChoose[hostNode] + choose[newNode], notChoose[hostNode] + notChoose[newNode]); } else if(p[i] == 1) { choose[hostNode] = max(max(choose[hostNode] + notChoose[newNode], notChoose[hostNode] + choose[newNode]), choose[hostNode] + choose[newNode]); notChoose[hostNode] = notChoose[hostNode] + choose[newNode]; } else { choose[hostNode] = max(choose[hostNode] + notChoose[newNode], notChoose[hostNode] + choose[newNode]); notChoose[hostNode] = notChoose[hostNode] + notChoose[newNode]; } } return max(choose[0], notChoose[0]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...