이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))
using namespace std;
const ll LINF = 1e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, a[mxN], b[2][mxN];
ll findGap(int T, int N){
vector<ll> a;
ll L = 0, R = LINF, l, r;
if (T == 1){
while (a.size() < N){
MinMax(L, R, &l, &r);
a.pb(l); a.pb(r);
L = l+1; R = r-1;
}
}
else{
MinMax(0, LINF, &L, &R);
a.pb(L); a.pb(R);
L++; R--;
ll d = (R-L+N-1) / (N-1);
r = L-1;
while (r < R){
l = r+1; r = l+d-1;
if (R-r < d) r = R;
ll mn, mx;
MinMax(l, r, &mn, &mx);
if (~mn){
a.pb(mn); a.pb(mx);
}
}
}
sort(all(a));
ll d = a[1] - a[0];
for (int i = 2; i < N; i++)
smax(d, a[i] - a[i-1]);
return d;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | while (a.size() < N){
| ~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |