#include<bits/stdc++.h>
#include "gap.h"
#define MAXN 600007
using namespace std;
struct interval{
long long from,to;
inline friend bool operator < (interval fr,interval sc){
return fr.to-fr.from<sc.to-sc.from;
}
};
priority_queue<interval> q;
interval check(long long l,long long r){
if(l+1==r)return {-1,-1};
long long mid=(l+r)/2;
long long *ll,*rr,*lt,*rt;
ll=new long long();
rr=new long long();
lt=new long long();
rt=new long long();
MinMax(l+1,mid, ll,rr);
MinMax(mid,r-1, lt,rt);
return {*rr,*lt};
}
const long long inf=1e18;
long long *l,*r;
long long findGap(int T, int N){
while(!q.empty())q.pop();
l=new long long();
r=new long long();
MinMax(1, inf, l,r);
q.push({*l,*r});
while(true){
if(q.size()>N)return 1/0;
interval s=check(q.top().from,q.top().to);
if(s.from==-1)return q.top().to-q.top().from;
interval z=q.top();
q.pop();
if(z.from!=s.from)q.push({z.from,s.from});
if(s.from!=s.to)q.push(s);
if(s.to!=z.to)q.push({s.to,z.to});
}
return 0;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:51:14: warning: comparison of integer expressions of different signedness: 'std::priority_queue<interval>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | if(q.size()>N)return 1/0;
| ~~~~~~~~^~
gap.cpp:51:25: warning: division by zero [-Wdiv-by-zero]
51 | if(q.size()>N)return 1/0;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 4 |
3 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
4 |
Runtime error |
2 ms |
4528 KB |
Execution killed with signal 4 |
5 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
9 |
Correct |
0 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Incorrect |
1 ms |
2648 KB |
Output isn't correct |
16 |
Incorrect |
9 ms |
2904 KB |
Output isn't correct |
17 |
Correct |
6 ms |
2904 KB |
Output is correct |
18 |
Incorrect |
6 ms |
2648 KB |
Output isn't correct |
19 |
Correct |
6 ms |
2904 KB |
Output is correct |
20 |
Correct |
3 ms |
2392 KB |
Output is correct |
21 |
Incorrect |
46 ms |
5832 KB |
Output isn't correct |
22 |
Runtime error |
110 ms |
21180 KB |
Execution killed with signal 4 |
23 |
Incorrect |
23 ms |
3796 KB |
Output isn't correct |
24 |
Correct |
30 ms |
3940 KB |
Output is correct |
25 |
Incorrect |
94 ms |
12480 KB |
Output isn't correct |
26 |
Correct |
33 ms |
4304 KB |
Output is correct |
27 |
Correct |
31 ms |
4044 KB |
Output is correct |
28 |
Correct |
37 ms |
4044 KB |
Output is correct |
29 |
Incorrect |
30 ms |
3796 KB |
Output isn't correct |
30 |
Correct |
8 ms |
2648 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
6 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
8 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 4 |
9 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
10 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
11 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
12 |
Runtime error |
3 ms |
4952 KB |
Execution killed with signal 4 |
13 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
15 |
Partially correct |
1 ms |
2648 KB |
Partially correct |
16 |
Incorrect |
7 ms |
2904 KB |
Output isn't correct |
17 |
Incorrect |
7 ms |
2792 KB |
Output isn't correct |
18 |
Partially correct |
11 ms |
2904 KB |
Partially correct |
19 |
Partially correct |
7 ms |
2904 KB |
Partially correct |
20 |
Partially correct |
2 ms |
2392 KB |
Partially correct |
21 |
Partially correct |
25 ms |
4052 KB |
Partially correct |
22 |
Incorrect |
28 ms |
3532 KB |
Output isn't correct |
23 |
Partially correct |
30 ms |
4016 KB |
Partially correct |
24 |
Partially correct |
26 ms |
4052 KB |
Partially correct |
25 |
Partially correct |
93 ms |
12412 KB |
Partially correct |
26 |
Incorrect |
24 ms |
3788 KB |
Output isn't correct |
27 |
Incorrect |
25 ms |
4052 KB |
Output isn't correct |
28 |
Incorrect |
26 ms |
4376 KB |
Output isn't correct |
29 |
Partially correct |
26 ms |
4044 KB |
Partially correct |
30 |
Partially correct |
7 ms |
2648 KB |
Partially correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |