Submission #1063347

#TimeUsernameProblemLanguageResultExecution timeMemory
1063347phoenixFriend (IOI14_friend)C++17
100 / 100
30 ms3504 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int f[n][2]; for (int i = 0; i < n; i++) { f[i][0] = 0; f[i][1] = confidence[i]; } for (int i = n - 1; i > 0; i--) { int x = host[i]; int p[2]; if (protocol[i] == 0) { p[0] = f[host[i]][0] + max(f[i][0], f[i][1]); p[1] = f[host[i]][1] + f[i][0]; } if (protocol[i] == 1) { p[0] = f[host[i]][0] + f[i][0]; p[1] = max({f[host[i]][1] + f[i][1], f[host[i]][0] + f[i][1], f[host[i]][1] + f[i][0]}); } if (protocol[i] == 2) { p[0] = f[host[i]][0] + f[i][0]; p[1] = max({f[host[i]][1] + f[i][0], f[host[i]][0] + f[i][1]}); } f[host[i]][0] = p[0]; f[host[i]][1] = p[1]; } return max(f[0][0], f[0][1]); }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:13:7: warning: unused variable 'x' [-Wunused-variable]
   13 |   int x = host[i];
      |       ^
friend.cpp:28:17: warning: 'p[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   f[host[i]][1] = p[1];
      |   ~~~~~~~~~~~~~~^~~~~~
friend.cpp:27:17: warning: 'p[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |   f[host[i]][0] = p[0];
      |   ~~~~~~~~~~~~~~^~~~~~
#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...