제출 #221810

#제출 시각아이디문제언어결과실행 시간메모리
221810patrikpavic2친구 (IOI14_friend)C++17
100 / 100
40 ms3448 KiB
/** * user: ppavic * fname: Patrik * lname: Pavić * task: friend * score: 100.0 * date: 2019-06-26 18:21:58.310586 */ #include "friend.h" #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #define X first #define Y second #define PB push_back using namespace std; typedef vector < int > vi; typedef pair < int, int > pii; typedef vector < pii > vp; const int N = 1e5 + 500; const int INF = 0x3f3f3f3f; int p[N], q[N]; void spoji0(int x,int y){ int np = p[x] + q[y]; int nq = max(p[y], q[y]) + q[x]; p[x] = np, q[x] = nq; } void spoji1(int x,int y){ int np = max(max(p[x] + p[y], p[x] + q[y]), p[y] + q[x]); int nq = q[x] + q[y]; p[x] = np, q[x] = nq; } void spoji2(int x,int y){ int np = max(p[x] + q[y], p[y] + q[x]); int nq = q[x] + q[y]; p[x] = np, q[x] = nq; } int findSample(int n,int cc[],int h[],int op[]){ for(int i = 0;i < n;i++) p[i] = cc[i]; for(int i = n - 1; i ;i--){ if(op[i] == 0) spoji0(h[i], i); if(op[i] == 1) spoji1(h[i], i); if(op[i] == 2) spoji2(h[i], 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...