제출 #404723

#제출 시각아이디문제언어결과실행 시간메모리
404723BERNARB01Gap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long findGap(int T, int N) { vector<long long> a; if (T == 1) { long long lb = 0, rb = (long long) 1e18L; a.resize(N); for (int i = 0; i < (N + 1) / 2; i++) { MinMax(lb, rb, &a[i], &a[N - 1 - i]); lb = a[i] + 1; rb = a[N - 1 - i] - 1; } long long ans = 0; for (int i = 1; i < N; i++) { ans = max(ans, a[i] - a[i - 1]); } return ans; } long long mn, mx; MinMax(0, 1e18L, &mn, &mx); if (N == 2) { return mx - mn; } if (N == 3) { long long nn; MinMax(0, mx - 1, mn, nn); return max(nn - mn, mx - nn); } long long len = (mx - mn - 1) / (N - 1); long long ans = len; a.push_back(mn); for (int i = 0; i < N - 1; i++) { long long m, M; if (mn + 1 == mx - 1) { a.push_back(mn + 1); break; } MinMax(mn + 1, min(mn + 1 + len, mx - 1), &m, &M); mn = mn + 1 + len; if (m == -1) { continue; } a.push_back(m); if (M != m) { a.push_back(M); } } a.push_back(mx); for (int i = 1; i < (int) a.size(); i++) { ans = max(ans, a[i] - a[i - 1]); } return ans; }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:21: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   29 |   MinMax(0, mx - 1, mn, nn);
      |                     ^~
      |                     |
      |                     long long int
In file included from gap.cpp:1:
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:29:25: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   29 |   MinMax(0, mx - 1, mn, nn);
      |                         ^~
      |                         |
      |                         long long int
In file included from gap.cpp:1:
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*);
      |                                               ^~~~~~~~~~