// ~ 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] += max(val[i][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] += val[i][0];
val[v][1] = max(val[v][1] + val[i][0], val[i][1]);
}
val[v][1] = max(val[v][1], val[v][0]);
//for(int j = 0; j < n; j++)
// cout << i << ' ' << j << ' ' << val[j][0] << ' ' << val[j][1] << endl;
}
return max(val[0][0], val[0][1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
11980 KB |
Output is correct |
2 |
Correct |
5 ms |
11988 KB |
Output is correct |
3 |
Correct |
7 ms |
12012 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
6 ms |
12096 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
6 ms |
11988 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
6 ms |
12028 KB |
Output is correct |
12 |
Correct |
5 ms |
11988 KB |
Output is correct |
13 |
Correct |
6 ms |
11968 KB |
Output is correct |
14 |
Correct |
6 ms |
11988 KB |
Output is correct |
15 |
Correct |
6 ms |
12080 KB |
Output is correct |
16 |
Correct |
5 ms |
11988 KB |
Output is correct |
17 |
Incorrect |
6 ms |
11988 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
12068 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 |
12116 KB |
Output is correct |
5 |
Correct |
6 ms |
12120 KB |
Output is correct |
6 |
Correct |
6 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
6 ms |
12116 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
12116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
12028 KB |
Output is correct |
2 |
Correct |
6 ms |
12116 KB |
Output is correct |
3 |
Correct |
7 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
6 ms |
12116 KB |
Output is correct |
6 |
Correct |
5 ms |
11988 KB |
Output is correct |
7 |
Correct |
5 ms |
11988 KB |
Output is correct |
8 |
Correct |
5 ms |
11988 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
12116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
11988 KB |
Output is correct |
2 |
Correct |
5 ms |
11988 KB |
Output is correct |
3 |
Correct |
5 ms |
11988 KB |
Output is correct |
4 |
Correct |
6 ms |
11988 KB |
Output is correct |
5 |
Correct |
6 ms |
12044 KB |
Output is correct |
6 |
Correct |
6 ms |
12084 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
6 ms |
12116 KB |
Output is correct |
9 |
Correct |
5 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
6 ms |
12056 KB |
Output is correct |
12 |
Correct |
6 ms |
12116 KB |
Output is correct |
13 |
Correct |
5 ms |
12116 KB |
Output is correct |
14 |
Correct |
5 ms |
11988 KB |
Output is correct |
15 |
Correct |
6 ms |
12116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 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 |
12016 KB |
Output is correct |
5 |
Correct |
5 ms |
12032 KB |
Output is correct |
6 |
Correct |
5 ms |
11988 KB |
Output is correct |
7 |
Correct |
6 ms |
11988 KB |
Output is correct |
8 |
Correct |
5 ms |
11988 KB |
Output is correct |
9 |
Correct |
6 ms |
12008 KB |
Output is correct |
10 |
Correct |
6 ms |
12124 KB |
Output is correct |
11 |
Correct |
6 ms |
12012 KB |
Output is correct |
12 |
Correct |
6 ms |
12096 KB |
Output is correct |
13 |
Correct |
6 ms |
11988 KB |
Output is correct |
14 |
Correct |
6 ms |
12116 KB |
Output is correct |
15 |
Correct |
6 ms |
12032 KB |
Output is correct |
16 |
Correct |
6 ms |
11988 KB |
Output is correct |
17 |
Correct |
6 ms |
12020 KB |
Output is correct |
18 |
Correct |
6 ms |
11988 KB |
Output is correct |
19 |
Correct |
6 ms |
11988 KB |
Output is correct |
20 |
Correct |
6 ms |
12116 KB |
Output is correct |
21 |
Correct |
6 ms |
12116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
11988 KB |
Output is correct |
2 |
Correct |
5 ms |
11988 KB |
Output is correct |
3 |
Correct |
6 ms |
11988 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 |
11988 KB |
Output is correct |
7 |
Correct |
5 ms |
12088 KB |
Output is correct |
8 |
Correct |
6 ms |
11988 KB |
Output is correct |
9 |
Correct |
6 ms |
11988 KB |
Output is correct |
10 |
Correct |
6 ms |
11988 KB |
Output is correct |
11 |
Correct |
6 ms |
12060 KB |
Output is correct |
12 |
Incorrect |
36 ms |
15552 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |