답안 #1083380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083380 2024-09-03T04:07:00 Z djs100201 Gap (APIO16_gap) C++17
컴파일 오류
0 ms 0 KB
#include "gap.h"
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ = 2e5 + 10, inf = (ll)2e9 * (ll)1e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll findGap(int T, int N) {
	if (T == 1) {
		vector<ll> res(N);
		ll l = 0, r = 1e18, mn, mx, lidx = 0, ridx = N - 1;
		for (int i = 0; i < (N + 1) / 2; i++) {
			MinMax(l, r, &mn, &mx);
			res[lidx++] = mn, res[ridx--] = mx;
			l = mn + 1, r = mx - 1;
		}

		ll ret = 0;
		for (int i = 1; i < N; i++)
			ret = max(ret, res[i] - res[i - 1]);
		return ret;
	} else {
		ll l = 0, r = 1e18, ret = 0;
		MinMax(l, r, &mn, &mx);
		r = mx;
		vector<ll> R;
		ll gap = mx - mn, new_gap = gap / N;
		R.push_back(mn);
		ll x = mn;
		while (1) {
			MinMax(x, x + new_gap, mn, mx);
			if (mx == -1) {
				// 사이에 없으면...
				//  걍 넘기자
				x += new_gap + 1;
			} else {
				R.push_back(mn);
				x = mx;
				if (mn == r)
					break;
			}
		}
		for (int i = 1; i < R.size(); i++)
			ret = max(ret, R[i] - R[i - 1]);
		return ret;
	}
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:26:17: error: 'mn' was not declared in this scope; did you mean 'm'?
   26 |   MinMax(l, r, &mn, &mx);
      |                 ^~
      |                 m
gap.cpp:26:22: error: 'mx' was not declared in this scope; did you mean 'x'?
   26 |   MinMax(l, r, &mn, &mx);
      |                      ^~
      |                      x
gap.cpp:33:18: error: 'new_gap' was not declared in this scope
   33 |    MinMax(x, x + new_gap, mn, mx);
      |                  ^~~~~~~
gap.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for (int i = 1; i < R.size(); i++)
      |                   ~~^~~~~~~~~~
gap.cpp:29:6: warning: unused variable 'gap' [-Wunused-variable]
   29 |   ll gap = mx - mn, new_gap = gap / N;
      |      ^~~