This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "friend.h"
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
typedef long long ll;
typedef pair < int , int > ii;
int n, m, cvp, ata[N], say[N], ne[N], ans[2][N];
int findSample(int n,int c[],int h[],int p[]){
ata[0] = ++m;
ans[0][1] = 1;
for(int i = 1; i < n; i++){
if(!say[h[i]] and p[i] == 1){
// cout << "AMK" << endl;
ata[i] = ++m;
ans[0][m]++;
ne[i] = 0;
continue;
}
ata[i] = ata[h[i]];
say[i]++;
say[h[i]]++;
if(p[i] == 0)
ne[i] = 1 - ne[h[i]];
else
ne[i] = ne[h[i]];
ans[ne[i]][ata[i]]++;
}
for(int i = 1; i <= m; i++)
cvp += max(ans[0][i], ans[1][i]);
return cvp;
}
// #define __MAXSIZE__ 100002
// using namespace std;
// int confidence[__MAXSIZE__];
// int host[__MAXSIZE__];
// int protocol[__MAXSIZE__];
// int main(void){
// freopen("in.txt", "r", stdin);
// freopen("outt.txt", "w", stdout);
// int n,i;
// assert(scanf("%d",&n)==1);
// for(i=0;i<n;i++)
// assert(scanf("%d",&confidence[i])==1);
// for(i=1;i<n;i++)
// assert(scanf("%d %d",&host[i],&protocol[i])==2);
// printf("%d\n",findSample(n,confidence,host,protocol));
// return 0;
// }
# | 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... |