제출 #48376

#제출 시각아이디문제언어결과실행 시간메모리
48376BTheroGap (APIO16_gap)C++17
0 / 100
28 ms1512 KiB
#include <bits/stdc++.h>
#include "gap.h"

#define pb push_back
#define all(x) (x).begin(), (x).end()

typedef long long ll;

using namespace std;

long long findGap(int T, int N) {
    vector <ll> a, b;

    a.pb(0);
    b.pb((ll)1e18 + 1);

    while (a.size() + b.size() < N) {
        ll *v1, *v2;

        MinMax(a.back() + 1, b.back() - 1, v1, v2);

        a.pb(*v1); b.pb(*v2);
    }

    reverse(all(b));

    for (auto it : b) {
        a.pb(it);
    }

    sort(all(a));
    a.resize(unique(all(a)) - a.begin());

    ll ret = 0;

    for (int i = 0; i + 1 < a.size(); ++i) {
        ret = max(ret, a[i + 1] - a[i]);
    }

	return ret;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:17:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (a.size() + b.size() < N) {
            ~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i + 1 < a.size(); ++i) {
                     ~~~~~~^~~~~~~~~~
gap.cpp:20:15: warning: 'v1' may be used uninitialized in this function [-Wmaybe-uninitialized]
         MinMax(a.back() + 1, b.back() - 1, v1, v2);
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp:20:15: warning: 'v2' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...