Submission #383949

#TimeUsernameProblemLanguageResultExecution timeMemory
383949mihai145Gap (APIO16_gap)C++14
0 / 100
34 ms1260 KiB
#include "gap.h" #include <vector> const long long INF = 1e18; long long findGap(int T, int N) { long long *a0, *aN; MinMax(0LL, INF, a0, aN); long long L = (*aN - *a0) / (N - 1); if(N == 2) { return L; } std::vector <long long> values; values.push_back(*a0); long long prevRightEnd = *a0; for(int i = 1; i <= N - 1; i++) { long long *mn, *mx; if(prevRightEnd + L - 1 < *aN) { MinMax(prevRightEnd + 1, prevRightEnd + L - 1, mn, mx); } else { if(prevRightEnd + 1 <= *aN - 1) { MinMax(prevRightEnd + 1, *aN - 1, mn, mx); } } prevRightEnd = prevRightEnd + L - 1; if(*mn != -1) { values.push_back(*mn); if(*mx != *mn) { values.push_back(*mx); } } } values.push_back(*aN); long long dif = 0; for(int i = 1; i < (int)values.size(); i++) { dif = std::max(dif, values[i] - values[i - 1]); } return dif; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:11: warning: 'a0' is used uninitialized in this function [-Wuninitialized]
    9 |     MinMax(0LL, INF, a0, aN);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~
gap.cpp:9:11: warning: 'aN' is used uninitialized in this function [-Wuninitialized]
gap.cpp:23:19: warning: 'mn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |             MinMax(prevRightEnd + 1, prevRightEnd + L - 1, mn, mx);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp:23:19: warning: 'mx' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...