Submission #284893

#TimeUsernameProblemLanguageResultExecution timeMemory
284893triplem5dsGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include "bits/stdc++.h" using namespace std; long long findGap(int T, int N) { long long ans = 0; long long mn, mx; if(T == 1){ vector<long long> L, R; long long LO = 0, HI = 1000000000000000000; while(L.size() + R.size() < N){ MinMax(LO,HI, & mn, & mx); L.push_back(*mn); R.push_back(*mx); LO = mn + 1; HI = mx - 1; } reverse(R.begin(),R.end()); if(N & 1) L.pop_back(); vector<long long> v; for(auto x : L)v.push_back(x); for(auto x : R)v.push_back(x); for(int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i-1]); } else { MinMax(0, 1000000000000000000, mn, mx); long long d = (mx - mn + N - 3) / (N - 1); vector<long long> v({mn, mx}); long long cur = mn + 1; while(cur < v[1]) { MinMax(cur, min(v[1] - 1, cur + d - 1), &mn, &mx); cur += d; if(mn == -1)continue; v.push_back(mn); v.push_back(mx); } sort(v.begin(),v.end()); for(int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i-1]); } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:31: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     while(L.size() + R.size() < N){
      |           ~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:15:20: error: invalid type argument of unary '*' (have 'long long int')
   15 |       L.push_back(*mn);
      |                    ^~
gap.cpp:16:20: error: invalid type argument of unary '*' (have 'long long int')
   16 |       R.push_back(*mx);
      |                    ^~
gap.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i =  1; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
gap.cpp:33:38: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   33 |       MinMax(0, 1000000000000000000, mn, mx);
      |                                      ^~
      |                                      |
      |                                      long long int
In file included from gap.cpp:1:
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:33:42: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   33 |       MinMax(0, 1000000000000000000, mn, mx);
      |                                          ^~
      |                                          |
      |                                          long long int
In file included from gap.cpp:1:
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*);
      |                                               ^~~~~~~~~~
gap.cpp:55:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |       for(int i = 1; i < v.size(); i++)
      |                      ~~^~~~~~~~~~