Submission #151852

#TimeUsernameProblemLanguageResultExecution timeMemory
151852qkxwsmFriend (IOI14_friend)C++14
100 / 100
38 ms3064 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() #define MAXN 100013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; int arr[MAXN]; int ans; int findSample(int n, int confidence[], int host[], int protocol[]) { N = n; FOR(i, 0, N) { arr[i] = confidence[i]; } //0 im: just a normal edge. 1 myf: they literally merge. 2 wereyourfriends: //so you somehow want to store like components and info about them. //whoever you end up marking, i'll mark them too. FORD(i, N, 1) { int p = host[i], qid = protocol[i]; if (qid == 0) { //i'm your friend. ans += arr[i]; arr[p] -= arr[i]; ckmax(arr[p], 0); } if (qid == 1) { //my friends are your friends. arr[p] += arr[i]; } if (qid == 2) { //we are your friends. ckmax(arr[p], arr[i]); } } ans += max(0, arr[0]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...