#include <cstdio>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
int x[2505], y[2505], hole[2505], n;
map<pi,int> mp;
int h;
int res;
struct bit{
int tree[266000], lim;
void init(int n) {
for(lim = 1; lim <= n; lim <<= 1);
}
void add(int x, int v){
x++;
while(x <= lim){
tree[x] += v;
x += x & -x;
}
}
int sum(int x){
x++;
int r = 0;
while(x){
r += tree[x];
x -= x & -x;
}
return r;
}
}bit;
double f(int s, int e){
if(s >= e) return 0;
int pos = (int)(min_element(y+s,y+e)-y);
int ph = h;
h = y[pos];
double r = max(f(s,pos),f(pos+1,e));
if(hole[pos] == 0 && r == 0){
res += (x[e] - x[s]) * (y[pos] - ph);
r = 0;
}
else{
r += 1.0 * (x[e] - x[s]) * (y[pos] - ph) / (bit.sum(e-1) - bit.sum(s-1));
}
h = ph;
return r;
}
int main(){
scanf("%d",&n);
n/=2;
for (int i=0; i<n; i++) {
scanf("%*d %*d %d %d",&x[i],&y[i]);
mp[pi(x[i],y[i])] = i;
}
bit.init(n);
int t;
scanf("%d",&t);
for (int i=0; i<t; i++) {
int s,e;
scanf("%d %d %*d %*d",&s,&e);
hole[mp[pi(s,e)]] = 1;
bit.add(mp[pi(s,e)],1);
}
printf("%.2lf\n",f(0,n-1));
printf("%d",res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2284 KB |
Output is correct |
2 |
Correct |
0 ms |
2284 KB |
Output is correct |
3 |
Correct |
0 ms |
2284 KB |
Output is correct |
4 |
Correct |
0 ms |
2284 KB |
Output is correct |
5 |
Correct |
0 ms |
2284 KB |
Output is correct |
6 |
Correct |
0 ms |
2284 KB |
Output is correct |
7 |
Correct |
0 ms |
2284 KB |
Output is correct |
8 |
Incorrect |
0 ms |
2284 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2284 KB |
Output is correct |
2 |
Correct |
1 ms |
2284 KB |
Output is correct |
3 |
Incorrect |
0 ms |
2284 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
3600 KB |
futex (syscall #202) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |