Submission #556893

#TimeUsernameProblemLanguageResultExecution timeMemory
556893SharkyGap (APIO16_gap)C++17
Compilation error
0 ms0 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long findGap(int T, int N) { if (T == 1) { pair<long long, long long> range = {1, inf}; long long cnt = 0, mn, mx; vector<long long> a; for (long long i = 0; i < (N + 1) / 2; i++) { MinMax(range.first, range.second, &mn, &mx); range = {mn + 1, mx - 1}; a.pb(mn); a.pb(mx); } sort(all(a)); long long ans = 0; for (long long i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]); return ans; } long long L = 1, R = inf, mn, mx; MinMax(L, R, &mn, &mx); long long hole = (mx - mn - 1 + (N - 1)) / (N - 1); long long MN, MX, i, ans = hole, lst = mn; for (i = mn; i + hole < mx; i += hole + 1) { MinMax(i, i + hole, &MN, &MX); if (MN != -1) ans = max(ans, MN - lst), lst = MX; } MinMax(i, mx, &MN, &MX); if (MN != -1) ans = max(ans, MN - lst); return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:6:48: error: 'inf' was not declared in this scope; did you mean 'ynf'?
    6 |         pair<long long, long long> range = {1, inf};
      |                                                ^~~
      |                                                ynf
gap.cpp:6:51: error: could not convert '{1, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<long long int, long long int>'
    6 |         pair<long long, long long> range = {1, inf};
      |                                                   ^
      |                                                   |
      |                                                   <brace-enclosed initializer list>
gap.cpp:12:15: error: 'class std::vector<long long int>' has no member named 'pb'
   12 |             a.pb(mn); a.pb(mx);
      |               ^~
gap.cpp:12:25: error: 'class std::vector<long long int>' has no member named 'pb'
   12 |             a.pb(mn); a.pb(mx);
      |                         ^~
gap.cpp:14:14: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   14 |         sort(all(a));
      |              ^~~
      |              std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from gap.cpp:2:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~
gap.cpp:7:19: warning: unused variable 'cnt' [-Wunused-variable]
    7 |         long long cnt = 0, mn, mx;
      |                   ^~~
gap.cpp:19:26: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   19 |     long long L = 1, R = inf, mn, mx;
      |                          ^~~
      |                          ynf
gap.cpp:20:19: error: 'mn' was not declared in this scope; did you mean 'yn'?
   20 |     MinMax(L, R, &mn, &mx);
      |                   ^~
      |                   yn
gap.cpp:20:24: error: 'mx' was not declared in this scope
   20 |     MinMax(L, R, &mn, &mx);
      |                        ^~