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