답안 #1083417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083417 2024-09-03T05:38:44 Z dong_gas Gap (APIO16_gap) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#include "gap.h"

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll a[100201];
ll l[100201], r[100201];
pll b[100201];
const ll inf = 1'000'000'000'000'000'000;

ll findGap(int T, int n) {
    if (T == 1) {
        ll L = 1, R = n, mn, mx;
        ll low = 0, high = 1e18;
        while (L < R) {
            MinMax(low, high, &mn, &mx);
            a[L++] = mn, a[R--] = mx;
            low = mn + 1, high = mx - 1;
        }
        if (L == R) {
            MinMax(low, high, &mn, &mx);
            a[L] = mn;
        }
        ll ret = 0;
        for (int i = 2; i <= n; i++) ret = max(ret, a[i] - a[i - 1]);
        return ret;
    }
    ll mn, mx, ret = 0;
    MinMax(0, inf, &mn, &mx);
    a[1] = mn, a[n] = mx;
    ll gap = (mx - mn + 1) / (n - 1);
    for (ll i = a[1], cnt = 1; cnt < n; i += gap, cnt++) {
        l[cnt] = i, r[cnt] = i + gap - 1;
        if (cnt + 1 == n) r[cnt] = a[n];
    }
    for (int i = 1; i < n; i++) {
        MinMax(l[i], r[i], mn, mx);
        b[i] = {mn, mx};
    }
    ll bef = -1;
    for (int i = 1; i < n; i++) {
        if (b[i].first == -1) continue;
        if (bef != -1) {
            MinMax(bef, b[i].first, &mn, &mx);
            ret = max(ret, mx - mn);
        }
        bef = b[i].second;
    }
    return ret;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:40:28: error: invalid conversion from 'll' {aka 'long long int'} to 'long long int*' [-fpermissive]
   40 |         MinMax(l[i], r[i], mn, mx);
      |                            ^~
      |                            |
      |                            ll {aka long long int}
In file included from gap.cpp:3:
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:40:32: error: invalid conversion from 'll' {aka 'long long int'} to 'long long int*' [-fpermissive]
   40 |         MinMax(l[i], r[i], mn, mx);
      |                                ^~
      |                                |
      |                                ll {aka long long int}
In file included from gap.cpp:3:
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*);
      |                                               ^~~~~~~~~~