Submission #163873

#TimeUsernameProblemLanguageResultExecution timeMemory
163873KubalionzzaleGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include <vector> #include <algorithm> #include <assert.h> long long findGap(int T, int N) { long long int minValue = 0, maxValue = 1e18; std::vector<int> vec; if (T == 1) { long long int left = 0, right = 0; do { MinMax(minValue, maxValue, &left, &right); if (left != -1) vec.push_back(left); if (right != left) vec.push_back(right); minValue = left + 1; maxValue = right - 1; } while (minValue <= maxValue && left != -1 && right != -1); assert(vec.size() == n); std::sort(vec.begin(), vec.end()); int maxi = 0; for (int i = 1; i < vec.size(); ++i) { if (vec[i] - vec[i - 1] > maxi) maxi = vec[i] - vec[i - 1]; } return maxi; } else { } }

Compilation message (stderr)

In file included from gap.cpp:4:0:
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:30: error: 'n' was not declared in this scope
         assert(vec.size() == n);
                              ^
gap.cpp:30:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < vec.size(); ++i)
                         ~~^~~~~~~~~~~~
gap.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^