Submission #266588

#TimeUsernameProblemLanguageResultExecution timeMemory
266588dCodingGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" #include <vector> #include <algorithm> long long findGap(int T, int N) { vector<ll> a; ll lo = 0, hi = 1e18; while(a.size() < N) { ll mn,mx; MinMax(lo,hi,mn,mx); if(mn == mx) { a.pb(mn); } else { a.pb(mn); a.pb(mx); hi = mx-1; lo = mn+1; assert(lo <= hi); } } ll ans = 0; sort(a.begin(),a.end()); FOR(i,1,n-1) ans = max(ans,a[i]-a[i-1]); return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:7:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    7 |     vector<ll> a;
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/9/vector:67,
                 from gap.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
gap.cpp:7:12: error: 'll' was not declared in this scope
    7 |     vector<ll> a;
      |            ^~
gap.cpp:7:16: error: 'a' was not declared in this scope
    7 |     vector<ll> a;
      |                ^
gap.cpp:8:7: error: expected ';' before 'lo'
    8 |     ll lo = 0, hi = 1e18;
      |       ^~~
      |       ;
gap.cpp:10:11: error: expected ';' before 'mn'
   10 |         ll mn,mx;
      |           ^~~
      |           ;
gap.cpp:11:16: error: 'lo' was not declared in this scope
   11 |         MinMax(lo,hi,mn,mx);
      |                ^~
gap.cpp:11:19: error: 'hi' was not declared in this scope
   11 |         MinMax(lo,hi,mn,mx);
      |                   ^~
gap.cpp:11:22: error: 'mn' was not declared in this scope
   11 |         MinMax(lo,hi,mn,mx);
      |                      ^~
gap.cpp:11:25: error: 'mx' was not declared in this scope
   11 |         MinMax(lo,hi,mn,mx);
      |                         ^~
gap.cpp:17:13: error: 'assert' was not declared in this scope
   17 |             assert(lo <= hi);
      |             ^~~~~~
gap.cpp:4:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    3 | #include <algorithm>
  +++ |+#include <cassert>
    4 | 
gap.cpp:20:7: error: expected ';' before 'ans'
   20 |     ll ans = 0;
      |       ^~~~
      |       ;
gap.cpp:21:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   21 |     sort(a.begin(),a.end());
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/9/algorithm:62,
                 from gap.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:4887:5: note: 'std::sort' declared here
 4887 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
gap.cpp:22:9: error: 'i' was not declared in this scope
   22 |     FOR(i,1,n-1) ans = max(ans,a[i]-a[i-1]);
      |         ^
gap.cpp:22:13: error: 'n' was not declared in this scope
   22 |     FOR(i,1,n-1) ans = max(ans,a[i]-a[i-1]);
      |             ^
gap.cpp:22:5: error: 'FOR' was not declared in this scope
   22 |     FOR(i,1,n-1) ans = max(ans,a[i]-a[i-1]);
      |     ^~~
gap.cpp:23:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |     return ans;
      |            ^~~
      |            abs