This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Source: https://oj.uz/problem/view/IOI14_friend?locale=en
//
#include "friend.h"
#include "bits/stdc++.h"
using namespace std;
#define s second
#define f first
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
typedef vector<ll> vi;
#define FOR(i, a, b) for (ll i = (a); i<b; i++)
bool ckmin(ll& a, ll b){ return b < a ? a = b, true : false; }
bool ckmax(ll& a, ll b){ return b > a ? a = b, true : false; }
const ll N = 1e5 + 10;
ll c[N];
int findSample(int n, int confidence[], int host[], int protocol[]) {
vi bst = {0, 0};
bst[0] += confidence[0];
c[0] = 0;
FOR(i, 1, n) {
// cout << ' ' << i << host[i] << protocol[i] << endl;
if (protocol[i] == 1) {
c[i] = c[host[i]];
bst[c[i]] += confidence[i];
} else if (protocol[i] == 0) {
c[i] = !c[host[i]];
bst[c[i]] += confidence[i];
} else {
bst[c[host[i]]] -= confidence[host[i]];
bst[c[host[i]]] += max(confidence[host[i]], confidence[i]);
}
// if (protocol[i] != 2) cout << i << bst[c[i]] << endl;
}
return max(bst[0], bst[1]);
}
// int main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ll n;
// cin >> n;
// vi c(n);
// FOR(i, 0, n) cin >> c[i];
// vi prot(n);
// vi host(n);
// FOR(i, 1, n) cin >> host[i] >> prot[i];
// cout << findSample(n, c, host, prot) << endl;
// }
# | 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... |