이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long x[100009];
const long long xmax = 1e18;
long long rand15 () {return rand () & 32767;}
long long rand30 () {return (rand15 () << 15LL) | rand15 ();}
long long rand60 () {return (rand30 () << 30LL) | rand30 ();}
vector < long long > divide (long long a, long long b)
{
if (a > b) return {};
long long mid = a + rand60 () % (b - a);
long long x, y, z, t;
MinMax (a, mid, &x, &y);
MinMax (mid + 1, b, &z, &t);
vector < long long > ans;
if (x == -1) ;
else
{
ans.push_back (x);
if (x != y)
{
vector < long long > curr;
curr = divide (x + 1, y - 1);
for (auto it : curr)
ans.push_back (it);
ans.push_back (y);
}
}
if (z == -1) ;
else
{
ans.push_back (z);
if (z != t)
{
vector < long long > curr;
curr = divide (z + 1, t - 1);
for (auto it : curr)
ans.push_back (it);
ans.push_back (t);
}
}
return ans;
}
long long findGap(int T, int N)
{
srand (time (0));
if (T == 1)
{
long long a = 0, b = xmax;
for (int i = 1, j = N; i<=j; i ++, j --)
MinMax (a, b, &x[i], &x[j]), a = x[i] + 1, b = x[j] - 1;
long long ans = x[2] - x[1];
for (int i=1; i<N; i++)
if (x[i + 1] - x[i] > ans)
ans = x[i + 1] - x[i];
return ans;
}
vector < long long > v = divide (0, xmax);
long long ans = v[1] - v[0];
for (int i=0; i<v.size () - 1; i++)
ans = max (ans, v[i + 1] - v[i]);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<v.size () - 1; i++)
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |