제출 #1182083

#제출 시각아이디문제언어결과실행 시간메모리
1182083tapilyoca친구 (IOI14_friend)C++20
100 / 100
385 ms3600 KiB
/*********************************************** * auth: tapilyoca * * date: 04/09/2025 at 21:26:08 * * dots: https://github.com/tapilyoca/dotilyoca * ***********************************************/ #include <bits/stdc++.h> #include "friend.h" using namespace std; const long long MOD = 1e9+7; using ll = int; using vll = vector<ll>; using pll = pair<ll,ll>; using str = string; #define dbg(x) cerr << #x << ": " << x << endl; /***********************************************/ ll findSample(ll n, ll conf[], ll host[], ll p[]) { ll out = 0; ll take[n], notake[n]; for(int i = 0; i < n; i++) { take[i] = conf[i]; notake[i] = 0; cerr << i << " " << take[i] << " " << notake[i] << endl; } for(int i = n-1; i >= 1; i--) { ll u = host[i]; ll v = i; if(p[i] == 0) { // i am your friend // either take u, take v, or take none take[u] = take[u] + notake[v]; notake[u] = max(notake[u] + notake[v], notake[u] + take[v]); } if(p[i] == 1) { // my friends are your friends // either take both, one, or none take[u] = max({take[u] + take[v], take[u] + notake[v], notake[u] + take[v]}); notake[u] = notake[u] + notake[v]; } if(p[i] == 2) { // we are your friends // either take u, take v, or take none take[u] = max(take[u] + notake[v], notake[u] + take[v]); notake[u] = notake[u] + notake[v]; } } return max(take[0], notake[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...