이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;
pll query(ll x, ll y){
pll p;
//cout<<x<<" "<<y<<endl;
MinMax(x, y, &p.first, &p.second);
return p;
}
vector<pll> vt;
vector<ll> v;
long long findGap(int T, int N){
if(T==1){
int s = 0, e = 1e18;
while(1){
pll p = query(s, e);
if(p.first==-1) break;
v.pb(p.first);
if(p.first==p.second) break;
v.pb(p.second);
s = p.first+1; e = p.second-1;
}
sort(v.begin(), v.end());
ll a = 0;
for(int i=0; i<v.size()-1; i++){
a = max(a, v[i+1]-v[i]);
}
return a;
}
pll p1 = query(0, 1e18);
if(N==2){
return p1.second-p1.first;
}
ll s = p1.first, e = p1.second;
if(e-s==2){
return 1LL;
}
ll L = (e-s-2)/N;
ll ans = L;
vt.pb({s, s});
ll n = s+1;
for(int i=0; i<N; i++){
if(n>=e) break;
pll p = query(n, min(n+L, e));
if(p.first!=-1){
vt.pb({p.first, p.second});
}
n+=L+1;
}
vt.pb({e, e});
for(int i=0; i<vt.size()-1; i++){
ans = max(ans, vt[i+1].first-vt[i].second);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:18: warning: overflow in implicit constant conversion [-Woverflow]
int s = 0, e = 1e18;
^~~~
gap.cpp:53:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size()-1; i++){
~^~~~~~~~~~~
gap.cpp:79:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<vt.size()-1; i++){
~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |