제출 #944615

#제출 시각아이디문제언어결과실행 시간메모리
944615wiiGap (APIO16_gap)C++17
컴파일 에러
0 ms0 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<ll> num;
void dnc(ll l, ll r, int T) {
    if (l > r)
        return;

    if (T == 1) {
        ll mn = -1, mx = -1;
        MinMax(l, r, &mn, &mx);

        dnc(mn + 1, mx - 1, T);
        num.push_back(mn);
        num.push_back(mx);
        return;
    }

    ll mid = (l + r) >> 1;
    ll mn = -1, mx = -1;

    MinMax(l, mid, &mn, &mx);
    if (mn != -1) {
        num.push_back(mn);
        num.push_back(mx);

        dnc(mn + 1, mx - 1);
        dnc(mid + 1, r);

        return;
    }

    if (mid + 1 <= r) {
        MinMax(mid, r, &mn, &mx);
        if (mn != -1) {
            num.push_back(mn);
            num.push_back(mx);

            dnc(mn + 1, mx - 1);
        }
    }
}

ll findGap(int T, int N) {
    dnc(0, 1e18, T);

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

    ll res = 0;
    for (int i = 1; i < num.size(); ++i)
        res = max(res, num[i] - num[i - 1]);

	return res;
}

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

gap.cpp: In function 'void dnc(ll, ll, int)':
gap.cpp:30:27: error: too few arguments to function 'void dnc(ll, ll, int)'
   30 |         dnc(mn + 1, mx - 1);
      |                           ^
gap.cpp:8:6: note: declared here
    8 | void dnc(ll l, ll r, int T) {
      |      ^~~
gap.cpp:31:23: error: too few arguments to function 'void dnc(ll, ll, int)'
   31 |         dnc(mid + 1, r);
      |                       ^
gap.cpp:8:6: note: declared here
    8 | void dnc(ll l, ll r, int T) {
      |      ^~~
gap.cpp:42:31: error: too few arguments to function 'void dnc(ll, ll, int)'
   42 |             dnc(mn + 1, mx - 1);
      |                               ^
gap.cpp:8:6: note: declared here
    8 | void dnc(ll l, ll r, int T) {
      |      ^~~
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 1; i < num.size(); ++i)
      |                     ~~^~~~~~~~~~~~
gap.cpp:53:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |     for (int i = 1; i < num.size(); ++i)
      |     ^~~
gap.cpp:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   56 |  return res;
      |  ^~~~~~