#include "gap.h"
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define ll long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
void query(ll L, ll R, ll *mn, ll *mx) {
if(L > R) *mn = -1, *mx = -1;
else MinMax(L, R, mn, mx);
}
long long findGap(int T, int N) {
if(T == 1) {
ll ans = 1, L = 0, R = 1e18, l, r;
int cnt = N;
query(L, R, &L, &R);
while(cnt > 2) {
cnt -= 2;
query(L + 1, R - 1, &l, &r);
if(l == -1) {
ans = max(ans, R - L);
break;
}
ans = max({ans, l - L, R - r});
L = l, R = r;
}
return max(ans, R - L);
}
else {
ll L = 0, R = 1e18, l, r;
query(L, R, &L, &R);
ll cur = ceil(R - L + 1, N - 1);
vector<ll> v;
v.push_back(L), L++;
while(L < R) {
query(L, L + cur, &l, &r);
if(l != -1) {
v.push_back(l);
v.push_back(r);
}
L = L + cur + 1;
}
v.push_back(R);
ll ans = 1;
rep(i, 1, signed(v.size()) - 1)
ans = max(ans, v[i] - v[i - 1]);
return ans;
}
}
Compilation message
gap.cpp:6: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
6 | #pragma loop-opt(on)
|
gap.cpp:21:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
gap.cpp:21:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
21 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
240 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
520 KB |
Output is correct |
17 |
Correct |
9 ms |
464 KB |
Output is correct |
18 |
Correct |
10 ms |
464 KB |
Output is correct |
19 |
Correct |
10 ms |
464 KB |
Output is correct |
20 |
Correct |
8 ms |
464 KB |
Output is correct |
21 |
Correct |
38 ms |
1064 KB |
Output is correct |
22 |
Correct |
34 ms |
1060 KB |
Output is correct |
23 |
Correct |
34 ms |
976 KB |
Output is correct |
24 |
Correct |
35 ms |
1056 KB |
Output is correct |
25 |
Correct |
39 ms |
1084 KB |
Output is correct |
26 |
Correct |
37 ms |
1080 KB |
Output is correct |
27 |
Correct |
36 ms |
968 KB |
Output is correct |
28 |
Correct |
41 ms |
992 KB |
Output is correct |
29 |
Correct |
37 ms |
1056 KB |
Output is correct |
30 |
Correct |
30 ms |
1008 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
14 ms |
848 KB |
Output is correct |
17 |
Correct |
15 ms |
872 KB |
Output is correct |
18 |
Correct |
13 ms |
848 KB |
Output is correct |
19 |
Correct |
15 ms |
852 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
55 ms |
2204 KB |
Output is correct |
22 |
Correct |
56 ms |
2216 KB |
Output is correct |
23 |
Correct |
53 ms |
2184 KB |
Output is correct |
24 |
Correct |
70 ms |
2204 KB |
Output is correct |
25 |
Correct |
57 ms |
3212 KB |
Output is correct |
26 |
Correct |
51 ms |
2240 KB |
Output is correct |
27 |
Correct |
55 ms |
2240 KB |
Output is correct |
28 |
Correct |
53 ms |
2240 KB |
Output is correct |
29 |
Correct |
51 ms |
2320 KB |
Output is correct |
30 |
Correct |
31 ms |
1468 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |