# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
554332 |
2022-04-28T07:13:26 Z |
Koosha_mv |
Gap (APIO16_gap) |
C++14 |
|
66 ms |
3300 KB |
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "gap.h"
typedef pair<ll,ll> pll;
const ll inf=1e18+99;
int n;
ll P(ll x,ll y){
return (x+y-1)/y;
}
pair<ll,ll> get(ll l,ll r){
ll mn,mx;
MinMax(l,r,&mn,&mx);
return {mn,mx};
}
ll findGap(int T, int _n){
n=_n;
if(T==1){
vector<ll> A;
pll last=get(0,inf);
A.pb(last.F);
A.pb(last.S);
f(i,0,(n-1)/2){
pll now=get(last.F+1,last.S-1);
last=now;
A.pb(now.F);
A.pb(now.S);
}
ll ans=0;
sort(all(A));
f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
return ans;
}
if(T==2){
vector<ll> A;
ll ans=0;
pll p=get(0,inf);
ll s=p.F,e=p.S,len=P(e-s,n-1);
ans=len;
A.pb(s);
A.pb(e);
for(ll l=s;l<=e;l+=len+1){
pll p=get(l,l+len);
A.pb(p.F);
A.pb(p.S);
}
sort(all(A));
f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
return ans;
}
return 0ll;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
53 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ~~~~~~~~~~~~
gap.cpp:53:3: note: in expansion of macro 'f'
53 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ^
gap.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
70 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ~~~~~~~~~~~~
gap.cpp:70:3: note: in expansion of macro 'f'
70 | f(i,1,A.size()) maxm(ans,abs(A[i]-A[i-1]));
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 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 |
848 KB |
Output is correct |
17 |
Correct |
11 ms |
808 KB |
Output is correct |
18 |
Correct |
11 ms |
880 KB |
Output is correct |
19 |
Correct |
10 ms |
848 KB |
Output is correct |
20 |
Correct |
10 ms |
848 KB |
Output is correct |
21 |
Correct |
40 ms |
2204 KB |
Output is correct |
22 |
Correct |
40 ms |
2208 KB |
Output is correct |
23 |
Correct |
40 ms |
2180 KB |
Output is correct |
24 |
Correct |
46 ms |
2204 KB |
Output is correct |
25 |
Correct |
37 ms |
2184 KB |
Output is correct |
26 |
Correct |
45 ms |
2232 KB |
Output is correct |
27 |
Correct |
41 ms |
2228 KB |
Output is correct |
28 |
Correct |
41 ms |
2164 KB |
Output is correct |
29 |
Correct |
47 ms |
2236 KB |
Output is correct |
30 |
Correct |
34 ms |
2240 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
18 ms |
1172 KB |
Output is correct |
17 |
Correct |
16 ms |
1084 KB |
Output is correct |
18 |
Correct |
18 ms |
1064 KB |
Output is correct |
19 |
Correct |
15 ms |
1076 KB |
Output is correct |
20 |
Correct |
8 ms |
1100 KB |
Output is correct |
21 |
Correct |
60 ms |
3236 KB |
Output is correct |
22 |
Correct |
58 ms |
3180 KB |
Output is correct |
23 |
Correct |
58 ms |
3224 KB |
Output is correct |
24 |
Correct |
59 ms |
3188 KB |
Output is correct |
25 |
Correct |
54 ms |
3260 KB |
Output is correct |
26 |
Correct |
57 ms |
3228 KB |
Output is correct |
27 |
Correct |
58 ms |
3180 KB |
Output is correct |
28 |
Correct |
63 ms |
3164 KB |
Output is correct |
29 |
Correct |
66 ms |
3300 KB |
Output is correct |
30 |
Correct |
31 ms |
3284 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |