#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#include "gap.h"
typedef long long ll;
vector<ll> a;
void solve1(ll l, ll r, int n){
ll lf = 1, rf = 1;
MinMax(l, r, &lf, &rf);
cout << lf << ' ' << rf << '\n';
if(lf == -1)return;
a.pb(lf);
if(lf != rf)a.pb(rf);
if(lf == rf || a.size() >= n)return;
l = lf + 1;
r = rf - 1;
if(l > r)return;
ll len = sqrt(r-l)+1;
ll last = l;
while(last <= r){
solve1(last, min(last + len, r), n);
last += len + 1;
}
}
long long findGap(int t, int n)
{
solve1(0, 1e18, n);
sort(all(a));
ll ans = 1;
for(int i = 1; i < a.size(); i++)
ans = max(ans, a[i] - a[i-1]);
return ans;
}
Compilation message
gap.cpp: In function 'void solve1(ll, ll, int)':
gap.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(lf == rf || a.size() >= n)return;
| ~~~~~~~~~^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 1; i < a.size(); i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Expected EOLN |
2 |
Execution timed out |
3019 ms |
652 KB |
Time limit exceeded |
3 |
Execution timed out |
3022 ms |
628 KB |
Time limit exceeded |
4 |
Execution timed out |
3027 ms |
920 KB |
Time limit exceeded |
5 |
Incorrect |
1 ms |
344 KB |
Expected EOLN |
6 |
Execution timed out |
3033 ms |
732 KB |
Time limit exceeded |
7 |
Execution timed out |
3008 ms |
688 KB |
Time limit exceeded (wall clock) |
8 |
Execution timed out |
3025 ms |
744 KB |
Time limit exceeded |
9 |
Execution timed out |
3012 ms |
664 KB |
Time limit exceeded |
10 |
Incorrect |
1 ms |
344 KB |
Expected EOLN |
11 |
Execution timed out |
3006 ms |
712 KB |
Time limit exceeded |
12 |
Execution timed out |
3051 ms |
680 KB |
Time limit exceeded |
13 |
Execution timed out |
3031 ms |
700 KB |
Time limit exceeded |
14 |
Execution timed out |
3024 ms |
648 KB |
Time limit exceeded |
15 |
Incorrect |
18 ms |
344 KB |
Expected EOLN |
16 |
Execution timed out |
3063 ms |
824 KB |
Time limit exceeded |
17 |
Execution timed out |
3014 ms |
880 KB |
Time limit exceeded |
18 |
Execution timed out |
3009 ms |
1112 KB |
Time limit exceeded |
19 |
Execution timed out |
3029 ms |
856 KB |
Time limit exceeded |
20 |
Incorrect |
12 ms |
980 KB |
Expected EOLN |
21 |
Execution timed out |
3028 ms |
1524 KB |
Time limit exceeded |
22 |
Execution timed out |
3011 ms |
1468 KB |
Time limit exceeded |
23 |
Execution timed out |
3051 ms |
1488 KB |
Time limit exceeded |
24 |
Execution timed out |
3060 ms |
1472 KB |
Time limit exceeded |
25 |
Incorrect |
133 ms |
2416 KB |
Expected EOLN |
26 |
Execution timed out |
3023 ms |
1468 KB |
Time limit exceeded |
27 |
Execution timed out |
3009 ms |
1428 KB |
Time limit exceeded |
28 |
Execution timed out |
3039 ms |
1352 KB |
Time limit exceeded |
29 |
Execution timed out |
3027 ms |
1364 KB |
Time limit exceeded |
30 |
Incorrect |
35 ms |
2244 KB |
Expected EOLN |
31 |
Execution timed out |
3049 ms |
668 KB |
Time limit exceeded |
32 |
Execution timed out |
3012 ms |
744 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Expected EOLN |
2 |
Execution timed out |
2796 ms |
656 KB |
Time limit exceeded (wall clock) |
3 |
Execution timed out |
3002 ms |
688 KB |
Time limit exceeded |
4 |
Execution timed out |
2870 ms |
656 KB |
Time limit exceeded (wall clock) |
5 |
Incorrect |
2 ms |
344 KB |
Expected EOLN |
6 |
Execution timed out |
3030 ms |
876 KB |
Time limit exceeded |
7 |
Execution timed out |
3037 ms |
744 KB |
Time limit exceeded (wall clock) |
8 |
Execution timed out |
2942 ms |
688 KB |
Time limit exceeded (wall clock) |
9 |
Execution timed out |
3008 ms |
672 KB |
Time limit exceeded |
10 |
Incorrect |
0 ms |
344 KB |
Expected EOLN |
11 |
Execution timed out |
3043 ms |
692 KB |
Time limit exceeded |
12 |
Execution timed out |
3037 ms |
664 KB |
Time limit exceeded |
13 |
Execution timed out |
3021 ms |
644 KB |
Time limit exceeded |
14 |
Execution timed out |
3027 ms |
924 KB |
Time limit exceeded |
15 |
Incorrect |
9 ms |
344 KB |
Expected EOLN |
16 |
Execution timed out |
3049 ms |
880 KB |
Time limit exceeded |
17 |
Execution timed out |
3005 ms |
808 KB |
Time limit exceeded |
18 |
Execution timed out |
3016 ms |
808 KB |
Time limit exceeded |
19 |
Execution timed out |
3036 ms |
848 KB |
Time limit exceeded |
20 |
Incorrect |
10 ms |
900 KB |
Expected EOLN |
21 |
Execution timed out |
3036 ms |
1364 KB |
Time limit exceeded |
22 |
Execution timed out |
3005 ms |
1324 KB |
Time limit exceeded |
23 |
Execution timed out |
3019 ms |
1464 KB |
Time limit exceeded |
24 |
Execution timed out |
3004 ms |
1384 KB |
Time limit exceeded |
25 |
Incorrect |
124 ms |
2372 KB |
Expected EOLN |
26 |
Execution timed out |
3005 ms |
1664 KB |
Time limit exceeded |
27 |
Execution timed out |
3025 ms |
1296 KB |
Time limit exceeded |
28 |
Execution timed out |
3020 ms |
1300 KB |
Time limit exceeded |
29 |
Execution timed out |
3002 ms |
1448 KB |
Time limit exceeded |
30 |
Incorrect |
39 ms |
2216 KB |
Expected EOLN |
31 |
Execution timed out |
3029 ms |
916 KB |
Time limit exceeded |
32 |
Execution timed out |
3002 ms |
688 KB |
Time limit exceeded |