Submission #586518

#TimeUsernameProblemLanguageResultExecution timeMemory
586518TekorFriend (IOI14_friend)C++17
100 / 100
25 ms3376 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define pii pair <int,int> #define f first #define s second #define mp make_pair #define pb push_back #define all(v) v.begin(),v.end() #define ll long long const int N = 3e5 + 100; const ll INF = (ll)1e9 + 7ll; int p[N],q[N]; int findSample(int n,int c[],int st[],int type[]){ for(int i = 0;i < n;i++) { p[i] = c[i]; q[i] = 0; } for(int i = n - 1;i >= 1;i--) { if(type[i] == 2) { p[st[i]] = max(p[st[i]] + q[i],p[i] + q[st[i]]); q[st[i]] = q[i] + q[st[i]]; }else if(type[i] == 1) { p[st[i]] = max(p[st[i]] + p[i],max(p[st[i]] + q[i],p[i] + q[st[i]])); q[st[i]] = q[st[i]] + q[i]; }else { p[st[i]] = p[st[i]] + q[i]; q[st[i]] = max(q[st[i]] + q[i],q[st[i]] + p[i]); } } return max(p[0],q[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...