Submission #131770

#TimeUsernameProblemLanguageResultExecution timeMemory
131770junodeveloperGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include "gap.h" long long findGap(int T, int N) { long long s, e, mn, mx, res = 0; if(T == 1) { s=0, e=1e18; vector<long long> v; while(s <= e) { MinMax(s, e, mn, mx); if(mn == -1) break; v.push_back(mn); v.push_back(mx); s = mn + 1, e = mx - 1; } sort(v.begin(), v.end()); for(int i=0; i+1<v.size(); i++) res = max(res, v[i+1] - v[i]); } else { s=0, e=1e18; MinMax(s, e, mn, mx); long long len = (mx - mn + N - 2) / (N - 1); vector<long long> v; while(s <= e) { MinMax(s, s + len, mn, mx); if(mn != -1) { v.push_back(mn); if(mn != mx) v.push_back(mx); } s += len + 1; } sort(v.begin(), v.end()); res = len; for(int i=0; i+1<v.size(); i++) res = max(res, v[i+1] - v[i]); } return 0; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:7:3: error: 'vector' was not declared in this scope
   vector<long long> v;
   ^~~~~~
gap.cpp:7:10: error: expected primary-expression before 'long'
   vector<long long> v;
          ^~~~
gap.cpp:9:23: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
    MinMax(s, e, mn, mx);
                       ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:9:23: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
    MinMax(s, e, mn, mx);
                       ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:11:4: error: 'v' was not declared in this scope
    v.push_back(mn);
    ^
gap.cpp:15:8: error: 'v' was not declared in this scope
   sort(v.begin(), v.end());
        ^
gap.cpp:15:3: error: 'sort' was not declared in this scope
   sort(v.begin(), v.end());
   ^~~~
gap.cpp:15:3: note: suggested alternative: 'short'
   sort(v.begin(), v.end());
   ^~~~
   short
gap.cpp:17:10: error: 'max' was not declared in this scope
    res = max(res, v[i+1] - v[i]);
          ^~~
gap.cpp:17:10: note: suggested alternative: 'mx'
    res = max(res, v[i+1] - v[i]);
          ^~~
          mx
gap.cpp:20:22: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   MinMax(s, e, mn, mx);
                      ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:20:22: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   MinMax(s, e, mn, mx);
                      ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:22:3: error: 'vector' was not declared in this scope
   vector<long long> v;
   ^~~~~~
gap.cpp:22:10: error: expected primary-expression before 'long'
   vector<long long> v;
          ^~~~
gap.cpp:24:29: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
    MinMax(s, s + len, mn, mx);
                             ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 3 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:24:29: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
    MinMax(s, s + len, mn, mx);
                             ^
In file included from gap.cpp:1:0:
gap.h:1:6: note:   initializing argument 4 of 'void MinMax(long long int, long long int, long long int*, long long int*)'
 void MinMax(long long, long long, long long*, long long*);
      ^~~~~~
gap.cpp:26:5: error: 'v' was not declared in this scope
     v.push_back(mn);
     ^
gap.cpp:31:8: error: 'v' was not declared in this scope
   sort(v.begin(), v.end());
        ^
gap.cpp:31:3: error: 'sort' was not declared in this scope
   sort(v.begin(), v.end());
   ^~~~
gap.cpp:31:3: note: suggested alternative: 'short'
   sort(v.begin(), v.end());
   ^~~~
   short
gap.cpp:34:10: error: 'max' was not declared in this scope
    res = max(res, v[i+1] - v[i]);
          ^~~
gap.cpp:34:10: note: suggested alternative: 'mx'
    res = max(res, v[i+1] - v[i]);
          ^~~
          mx