# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671191 | Ronin13 | Friend (IOI14_friend) | C++14 | 23 ms | 3408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
// Find out best sample
const int nmax = 1e5 + 1;
int dp[nmax][2];
int findSample(int n,int confidence[],int host[],int protocol[]){
int ans = 0;
for(int i = 0; i < n; i++){
dp[i][0] = confidence[i];
dp[i][1] = 0;
}
for(int i= n - 1; i > 0; i--){
int p = host[i];
if(protocol[i] == 0){
dp[p][1] = max(dp[i][0], dp[i][1]) + dp[p][1];
dp[p][0] = dp[p][0] + dp[i][1];
}
if(protocol[i] == 1){
dp[p][0] = max({dp[p][0] + dp[i][1], dp[p][1] + dp[i][0], dp[i][0] + dp[p][0]});
dp[p][1] = dp[p][1] + dp[i][1];
}
if(protocol[i] == 2){
dp[p][0] = max({dp[p][0] + dp[i][1], dp[p][1] + dp[i][0]});
dp[p][1] = dp[p][1] + dp[i][1];
}
}
return max(dp[0][0], dp[0][1]);
}
Compilation message (stderr)
# | 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... |