이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |