Submission #770630

#TimeUsernameProblemLanguageResultExecution timeMemory
770630EnchomGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <stdio.h> #include <vector> #include "gap.h" using namespace std; typedef long long llong; const llong MAXVAL = 1000000000000000000LL; llong solveSmall(int N) { llong minVal, maxVal; llong L = 0, R = MAXVAL; int pL = 0, pR = N - 1; vector<llong> nums(N); while(pL <= pR) { MinMax(L, R, &minVal, &maxVal); nums[pL] = minVal; nums[pR] = maxVal; pL++; pR--; L = minVal + 1; R = maxVal - 1; } llong ans = 0; for (int i = 1; i < nums.size(); i++) { ans = max(ans, nums[i] - nums[i - 1]); } return ans; } llong solveBig(int N) { llong minVal, maxVal; llong curVal, endVal; llong bestGap = 0; MinMax(0, MAXVAL, &curVal, &endVal); llong curGap = (endVal - curVal) / (N - 1); if ( (endVal - curVal) % (N - 1) != 0 ) curGap++; curGap--; bestGap = curGap; while(curVal != endVal) { MinMax(curVal + 1, curVal + curGap, minVal, maxVal); if (minVal == -1) { bestGap = max(bestGap, curGap); curGap = curGap * 2 + 2; } else { bestGap = max(bestGap, minVal - curVal); curGap = bestGap; curVal = maxVal; } } return bestGap; } llong findGap(int T, int N) { if (T == 1) return solveSmall(N); else return solveBig(N); } /* int main() { } */

Compilation message (stderr)

gap.cpp: In function 'llong solveSmall(int)':
gap.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 1; i < nums.size(); i++)
      |                     ~~^~~~~~~~~~~~~
gap.cpp: In function 'llong solveBig(int)':
gap.cpp:55:45: error: invalid conversion from 'llong' {aka 'long long int'} to 'long long int*' [-fpermissive]
   55 |         MinMax(curVal + 1, curVal + curGap, minVal, maxVal);
      |                                             ^~~~~~
      |                                             |
      |                                             llong {aka long long int}
In file included from gap.cpp:4:
gap.h:1:35: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                   ^~~~~~~~~~
gap.cpp:55:53: error: invalid conversion from 'llong' {aka 'long long int'} to 'long long int*' [-fpermissive]
   55 |         MinMax(curVal + 1, curVal + curGap, minVal, maxVal);
      |                                                     ^~~~~~
      |                                                     |
      |                                                     llong {aka long long int}
In file included from gap.cpp:4:
gap.h:1:47: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
    1 | void MinMax(long long, long long, long long*, long long*);
      |                                               ^~~~~~~~~~