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 <bits/stdc++.h>
#include "friend.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1010;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
int cho[MAXN], ncho[MAXN]; //choose, not choose
int findSample (int N, int C[], int H[], int type[]) {
for (int i = 0; i < N; i++) {
cho[i] = C[i];
}
//ok let's do this
for (int y = N - 1; y >= 1; y--) {
int x = H[y];
if (type[y] == 0) {
//IAmYourFriend
tie(cho[x], ncho[x]) = pii(cho[x] + ncho[y], max(ncho[x] + cho[y], ncho[x] + ncho[y]));
} else if (type[y] == 1) {
//MyFriendsAreYourFriends
//we can just combine them
tie(cho[x], ncho[x]) = pii(max({cho[x] + cho[y], cho[x] + ncho[y], ncho[x] + cho[y]}), ncho[x] + ncho[y]);
} else if (type[y] == 2) {
//WeAreYourFriends
tie(cho[x], ncho[x]) = pii(max(cho[x] + ncho[y], ncho[x] + cho[y]), ncho[x] + ncho[y]);
} else {
assert(!"Bad type");
}
}
return max(cho[0], ncho[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... |