답안 #963644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963644 2024-04-15T12:17:40 Z Acanikolic Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#include "gap.h"

#define F first

#define S second

using namespace std;

const int N = 2e5 + 10;

const long long inf = 1000000000000000000ll;

/*long long a[N];
int n;

void MinMax(long long s,long long t,long long &mn,long long &mx) {
    for(int i = 1; i <= n; i++) {
        if(a[i] >= s) {
            mn = a[i];
            break;
        }
    }
    for(int i = 1; i <= n; i++) {
        if(a[i] <= t) mx = a[i];
    }
}
*/
long long findGap(int t,int n) {
    long long L,R,s = -1,tt = inf + 1;
    long long res = inf;
    vector<long long>vec;
    for(int i = 1; i <= (n + 1) / 2; i++) {
        MinMax(s + 1,tt - 1,L,R);
        s = L;
        tt = R;
        if(L != -1) vec.push_back(L);
        if(R != -1 && L != R) vec.push_back(R);
    }
    sort(vec.begin(),vec.end());
    for(int i = 1; i < vec.size(); i++) res = min(res,vec[i] - vec[i - 1]);
    return res;
}

/*signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    cout << findGap(1,n);
    return 0;
}*/

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:35:29: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   35 |         MinMax(s + 1,tt - 1,L,R);
      |                             ^
      |                             |
      |                             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:35:31: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   35 |         MinMax(s + 1,tt - 1,L,R);
      |                               ^
      |                               |
      |                               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*);
      |                                               ^~~~~~~~~~
gap.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 1; i < vec.size(); i++) res = min(res,vec[i] - vec[i - 1]);
      |                    ~~^~~~~~~~~~~~