제출 #1223300

#제출 시각아이디문제언어결과실행 시간메모리
1223300minggaGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
#include "gap.h"

using namespace std;

#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 2e18
#define fast_cin()                  \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define out(file) freopen(file, "w", stdout)
#define in(file) freopen(file, "r", stdin)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
int MOD = 1e9 + 7;

ll findGap(int T, int N) {
    if(T == 1) {
        ll mn, mx;
        ll lb = 0, rb = 1e18;
        int l = 0, r = N - 1;
        vector<ll> a(N, 0);
        while(l <= r) {
            MinMax(lb, rb, &mn, &mx);
            a[l] = mn, a[r] = mx;
            lb = mn + 1, rb = mx - 1;
            l++,
            r--;
        }
        ll ans = 0;
        for(int i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]);
        return ans;
    } else {
        ll ans = 0;
        ll mx, mn, s = 0, t = 1e18;
        MinMax(s, t, &mn, &mx);
        if(n == 2) return mx - mn;
        ll gap = (mx - mn + 1) / n;
        s = mn + 1, t = mx - 1;
        ll lst = mn;
        while(s + gap + 1 <= t) {
            MinMax(s, s + gap, &mn, &mx);
            if(mn != -1) ans = max(ans, mn - lst), lst = mx;
            s += gap + 1;
        }
        MinMax(s, t, &mn, &mx);
        if(mn != -1) ans = max(ans, mn - lst), lst - mx;
        ans = max(ans, t + 1 - lst)
        return ans;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:12: error: 'n' was not declared in this scope
   43 |         if(n == 2) return mx - mn;
      |            ^
gap.cpp:44:34: error: 'n' was not declared in this scope
   44 |         ll gap = (mx - mn + 1) / n;
      |                                  ^
gap.cpp:54:36: error: expected ';' before 'return'
   54 |         ans = max(ans, t + 1 - lst)
      |                                    ^
      |                                    ;
   55 |         return ans;
      |         ~~~~~~                      
gap.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^