제출 #1147497

#제출 시각아이디문제언어결과실행 시간메모리
1147497iah친구 (IOI14_friend)C++20
100 / 100
16 ms2372 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair < int , int > #define fi first #define se second #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i ++) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i --) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i ++) #define bit(x, i) (((x) >> (i)) & 1ll) #define mask(x) (1ll << (x)) #define mem(f, x) memset(f, x, sizeof(f)) #define sz(x) (int32_t) (x.size()) const int nmax = 1e5; int dp[nmax + 7][2]; int findSample(int n,int confidence[],int host[],int protocol[]){ FORD(i, n - 1, 0) { dp[i][1] = confidence[i]; dp[i][0] = 0; } FORD(i, n - 1, 1) { int j = host[i], type = protocol[i]; if (type == 0) { dp[j][1] += dp[i][0]; dp[j][0] += max(dp[i][1], dp[i][0]); } else if (type == 1) { dp[j][1] += dp[i][1]; dp[j][0] += dp[i][0]; } else if (type == 2) { dp[j][1] = max(dp[j][0] + dp[i][1], dp[j][1] + dp[i][0]); dp[j][0] += dp[i][0]; } dp[j][1] = max(dp[j][1], dp[j][0]); // cout << i << " " << dp[i][0] << " " << dp[i][1] << "\n"; } int ans = 0; REP(i, n) { REP(j, 2){ ans = max(ans, dp[i][j]); } } 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...