답안 #946683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946683 2024-03-14T22:15:47 Z Ice_man Gap (APIO16_gap) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>

#include "gap.h"

#define maxn 200005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;

#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")

using namespace std;

std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;

double timePassed()
{
    using namespace std::chrono;
    currT = high_resolution_clock::now();
    double time = duration_cast<duration<double>>(currT - startT).count();
    return time * TIME_MULT;
}

vector <long long> nums;


/**void MinMax(long long l , long long r , long long& mn , long long& mx)
{
    cout << l << " " << r << endl;
    int a , b;

    cin >> a >> b;
    mn = a;
    mx = b;
}*/

long long findGap(int t , int n)
{
    long long l = 1;
    long long r = LINF;

    int q = ((n + 1) / 2);

    while(q--)
    {
        long long mn , mx;
        MinMax(l , r , mn , mx);

        nums.pb(mn);
        nums.pb(mn);

        l = mn + 1;
        r = mx - 1;
    }

    sort(nums.begin() , nums.end());

    long long ans = LINF;

    for(int i = 1; i < nums.size(); i++)
        ans = min(ans , abs(nums[i] - nums[i - 1]));

    return ans;
}


/**int main()
{
    int t , n;
    cin >> t >> n;
    findGap(t , n);

    return 0;
}*/



Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:57:24: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   57 |         MinMax(l , r , mn , mx);
      |                        ^~
      |                        |
      |                        long long int
In file included from gap.cpp:6:
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:57:29: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   57 |         MinMax(l , r , mn , mx);
      |                             ^~
      |                             |
      |                             long long int
In file included from gap.cpp:6:
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:70:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(int i = 1; i < nums.size(); i++)
      |                    ~~^~~~~~~~~~~~~