Submission #126873

#TimeUsernameProblemLanguageResultExecution timeMemory
126873ekremFriend (IOI14_friend)C++98
16 / 100
3 ms504 KiB
#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, al[N], alma[N]; int findSample(int n,int c[],int h[],int p[]){ for(int i = 0; i < n; i++){ al[i] = c[i]; alma[i] = 0; } for(int y = n - 1; y >= 1; y--){ int x = h[x]; if(p[y] == 2){ alma[x] = alma[x] + alma[y]; al[x] = max(al[y] + alma[x], alma[y] + al[x]); } else if(p[y] == 1){ alma[x] = alma[x] + alma[y]; al[x] = max(max(al[x] + alma[y], alma[x] + al[y]), al[x] + al[y]); } else{ alma[x] = alma[x] + max(al[y], alma[y]); al[x] = al[x] + alma[y]; } } return max(al[0], alma[0]); } // #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; // }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:27:14: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int x = h[x];
              ^
#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...