#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second
ll MOD = 1000000007;
ll power(ll base, ll n){
if (n == 0) return 1;
if (n == 1) return base;
ll halfn = power(base, n/2);
if (n % 2 == 0) return (halfn * halfn) % MOD;
return (((halfn * halfn) % MOD) * base) % MOD;
}
ll inverse(ll n){
return power(n, MOD-2);
}
ll add(ll a, ll b){
return (a+b) % MOD;
}
ll mul(ll a, ll b){
a %= MOD;
return (a*b) % MOD;
}
ll gcd(ll a, ll b){
if (a == 1) return 1;
if (a == 0) return b;
return gcd(b%a, a);
}
ll INF = (MOD-7)*(MOD-7);
ll findGap(int t, int n){
if (t == 1){
vector<ll> a;
ll L = 0, R = INF;
FOR(i,0,(n+1)/2){
ll mn, mx;
MinMax(L,R,&mn,&mx);
a.pb(mn); a.pb(mx);
L = mn+1, R = mx-1;
}
sort(a.begin(), a.end());
ll maxi = 0;
FOR(i,1,a.size()){
maxi = max(maxi, a[i]-a[i-1]);
}
return maxi;
}
ll L, R;
MinMax(0,INF,&L,&R);
ll len = R-L-1;
ll sz = len / (n-1);
ll curl = L+1, curr;
vector<ll> a; a.pb(L);
FOR(i,0,n-1){
curr = curl + sz - 1 + (len%(n-1) > i);
ll mn, mx;
MinMax(curl,curr,&mn,&mx);
if (mn != -1){
a.pb(mn);
a.pb(mx);
}
curl = curr+1;
}
a.pb(R);
ll ans = 0;
FOR(i,1,a.size()){
ans = max(ans, a[i]-a[i-1]);
}
return ans;
}
Compilation message
gap.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization ("Ofast")
|
gap.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
7 | #pragma GCC optimization ("unroll-loops")
|
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:15:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
64 | FOR(i,1,a.size()){
| ~~~~~~~~~~~~
gap.cpp:64:3: note: in expansion of macro 'FOR'
64 | FOR(i,1,a.size()){
| ^~~
gap.cpp:15:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
87 | FOR(i,1,a.size()){
| ~~~~~~~~~~~~
gap.cpp:87:2: note: in expansion of macro 'FOR'
87 | FOR(i,1,a.size()){
| ^~~
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
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 |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
816 KB |
Output is correct |
17 |
Correct |
10 ms |
816 KB |
Output is correct |
18 |
Correct |
10 ms |
892 KB |
Output is correct |
19 |
Correct |
10 ms |
848 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
40 ms |
2172 KB |
Output is correct |
22 |
Correct |
44 ms |
2220 KB |
Output is correct |
23 |
Correct |
38 ms |
2248 KB |
Output is correct |
24 |
Correct |
41 ms |
2200 KB |
Output is correct |
25 |
Correct |
35 ms |
2196 KB |
Output is correct |
26 |
Correct |
45 ms |
2244 KB |
Output is correct |
27 |
Correct |
40 ms |
2232 KB |
Output is correct |
28 |
Correct |
40 ms |
2216 KB |
Output is correct |
29 |
Correct |
39 ms |
2208 KB |
Output is correct |
30 |
Correct |
33 ms |
2204 KB |
Output is correct |
31 |
Correct |
0 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 |
1 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 |
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 |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
848 KB |
Output is correct |
17 |
Correct |
12 ms |
848 KB |
Output is correct |
18 |
Correct |
13 ms |
848 KB |
Output is correct |
19 |
Correct |
13 ms |
808 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
52 ms |
2204 KB |
Output is correct |
22 |
Correct |
52 ms |
2168 KB |
Output is correct |
23 |
Correct |
51 ms |
2240 KB |
Output is correct |
24 |
Correct |
50 ms |
2180 KB |
Output is correct |
25 |
Correct |
48 ms |
3224 KB |
Output is correct |
26 |
Correct |
53 ms |
2208 KB |
Output is correct |
27 |
Correct |
49 ms |
2164 KB |
Output is correct |
28 |
Correct |
51 ms |
2204 KB |
Output is correct |
29 |
Correct |
53 ms |
2244 KB |
Output is correct |
30 |
Correct |
30 ms |
1460 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |