이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int dp[2][100001];
int findSample(int n,int confidence[],int host[],int protocol[])
{
for (int i = 0; i < n; i++)
dp[1][i] = confidence[i];
for (int i = n - 1; i > 0; i--)
{
if ( protocol[i] == 0 )
{
dp[1][host[i]] = dp[1][host[i]] + dp[0][i];
dp[0][host[i]] = max(dp[0][i] + dp[0][host[i]], dp[1][i] + dp[0][host[i]]);
} else if ( protocol[i] == 1 ) {
dp[1][host[i]] = max(max(dp[1][host[i]] + dp[0][i], dp[1][host[i]] + dp[1][i]), dp[0][host[i]] + dp[1][i]);
dp[0][host[i]] = dp[0][host[i]] + dp[0][i];
} else {
dp[1][host[i]] = max(dp[1][host[i]] + dp[0][i], dp[1][i] + dp[0][host[i]]);
dp[0][host[i]] = dp[0][host[i]] + dp[0][i];
}
}
return max(dp[0][0], dp[1][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... |