// ~ Be Name Khoda ~ //
#include "friend.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e5 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
int cmp[maxn5], hs[maxn5], ty[maxn5];
ll val[maxn5][2];
int n, dp[maxn5][2], mat[maxn5];
vector <int> adj[maxn5];
bool mark[maxn5];
// Find out best sample
int findSample(int n,int confidence[], int host[], int protocol[]){
::n = n;
for(int i = 1; i < n; i++){
val[i][1] = confidence[i];
hs[i] = host[i];
ty[i] = protocol[i];
}
val[0][1] = confidence[0];
for(int i = n - 1; i; i--){
int v = hs[i];
if(ty[i] == 0){
val[v][0] += val[i][1];
val[v][1] += val[i][0];
}
if(ty[i] == 1){
val[v][0] += val[i][0];
val[v][1] += val[i][1];
}
if(ty[i] == 2){
val[v][0] = max(val[v][0], val[i][0]);
val[v][1] = max(val[v][1], val[i][1]);
}
}
return max(val[0][0], val[0][1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
11988 KB |
Output is correct |
2 |
Correct |
6 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
12036 KB |
Output is correct |
5 |
Correct |
6 ms |
12072 KB |
Output is correct |
6 |
Correct |
8 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
12052 KB |
Output is correct |
8 |
Incorrect |
6 ms |
11988 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
12036 KB |
Output is correct |
2 |
Correct |
7 ms |
12052 KB |
Output is correct |
3 |
Correct |
6 ms |
12068 KB |
Output is correct |
4 |
Correct |
6 ms |
12116 KB |
Output is correct |
5 |
Correct |
6 ms |
12116 KB |
Output is correct |
6 |
Correct |
6 ms |
12060 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
6 ms |
12124 KB |
Output is correct |
9 |
Correct |
6 ms |
12024 KB |
Output is correct |
10 |
Correct |
6 ms |
12068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11988 KB |
Output is correct |
2 |
Correct |
7 ms |
12060 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 KB |
Output is correct |
4 |
Correct |
7 ms |
12008 KB |
Output is correct |
5 |
Correct |
6 ms |
12064 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Correct |
8 ms |
12052 KB |
Output is correct |
8 |
Correct |
6 ms |
12104 KB |
Output is correct |
9 |
Correct |
7 ms |
12028 KB |
Output is correct |
10 |
Correct |
6 ms |
12116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12052 KB |
Output is correct |
2 |
Correct |
5 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
12092 KB |
Output is correct |
4 |
Correct |
6 ms |
12028 KB |
Output is correct |
5 |
Correct |
6 ms |
12116 KB |
Output is correct |
6 |
Incorrect |
6 ms |
12116 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
12040 KB |
Output is correct |
2 |
Correct |
6 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
12056 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
6 ms |
11988 KB |
Output is correct |
6 |
Correct |
6 ms |
12060 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
6 ms |
12004 KB |
Output is correct |
9 |
Correct |
8 ms |
12056 KB |
Output is correct |
10 |
Correct |
6 ms |
12136 KB |
Output is correct |
11 |
Incorrect |
6 ms |
11988 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12060 KB |
Output is correct |
2 |
Correct |
6 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11992 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
6 ms |
12020 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Incorrect |
6 ms |
12048 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |