이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt,sse3,avx")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
const int mod = ll(1e9)+7; //(b + (a%b)) % b (to mod -1%(10^9+7) correctly in c++ its -1 but its suppose to be 10^9+6
const ll MOD = 998244353; // (a%mod)*(binpow(b,mod-2,mod) = (a/b)%mod
const int M = ll(2e5) + 100;
const long long inf = 2e18;
//const long double eps = 1e-15L;
ll lcm(ll a, ll b) { return (a / __gcd(a,b))*b; }
ll binpow(ll a, ll b, ll m) { ll res=1; a %= m; while(b>0){ if(b&1)res=(res * a) % m; a=(a * a) % m; b/=2; } return res%m;}
void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
void MinMax(long long, long long, long long *, long long *);
long long n, a[M + 10];
long long solve1() {
long long l = 1, r = n, low = 0, high = 1e18;
while(l <= r) {
MinMax(low, high, &a[l], &a[r]);
low = a[l ++] + 1;
high = a[r --] -1;
}
long long ans = 0;
for(int i = 1; i < n; i ++) ans = max(ans, a[i + 1] - a[i]);
return ans;
}
long long solve2() {
MinMax(0ll, 1LL * 1e18, &a[1], &a[n]);
long long block = (a[n] - a[1] + n - 2) / (n - 1), ans = 0, prev = a[1];
for(long long l = a[1]; l < a[n]; l += block) {
long long x = 0, y = 0;
MinMax(l + 1, min(a[n], l + block), &x, &y);
if(y != -1) {
ans = max(ans, y - prev);
prev = y;
}
}
return ans;
}
long long findGap(int T, int N)
{
n = N;
if(T == 1) return solve1();
return solve2();
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'void Freopen(std::string)':
gap.cpp:35:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gap.cpp:35:76: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | void Freopen(string Key){ freopen((Key+".in").c_str(), "r", stdin); freopen((Key+".out").c_str(), "w", stdout); }
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |