답안 #1015176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015176 2024-07-06T07:02:36 Z vjudge1 Gap (APIO16_gap) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.cpp"
#include "gap.h"

using namespace std;

typedef long long ll;
set<ll> st;
void recur(ll l, ll r){
    if (r < l) return ;
    if (r - l <= 1){
        MinMax(l, r, &l, &r);
        if (l != -1){
            st.insert(l);
            st.insert(r);
        }
        return ;
    }

    ll mid = (l + r) / 2;
    
    ll mn, mx;
    MinMax(l, mid, &mn, &mx);

    if (mn != -1){
        st.insert(mn);
        st.insert(mx);
        recur(mn + 1, mx - 1);
    }

    MinMax(mid + 1, r, &mn, &mx);
    if (mn != -1){
        st.insert(mn);
        st.insert(mx);
        recur(mn + 1, mx - 1);
    }
}

ll findGap(int T, int N){
    if (T == 1){
        ll mn = 0, mx = 1e18;
        while (N > 0){
            N -= 2;

            MinMax(mn, mx, &mn, &mx);

            st.insert(mn);
            st.insert(mx);
            
            mn++;
            mx--;
        }
    }
    else{
        recur(0, 1e18);
    }

    vector<ll> vec;
        for (ll x : st)
            vec.push_back(x);

    ll res = 0;
    for (ll i = 1; i < vec.size(); i ++)
        res = max(res, vec[i] - vec[i - 1]);
    return res;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:63:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (ll i = 1; i < vec.size(); i ++)
      |                    ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccWPScAZ.o: in function `MinMax(long long, long long, long long*, long long*)':
grader.cpp:(.text+0x0): multiple definition of `MinMax(long long, long long, long long*, long long*)'; /tmp/ccmLNanZ.o:gap.cpp:(.text+0x1c0): first defined here
/usr/bin/ld: /tmp/ccWPScAZ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmLNanZ.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status