This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
struct data{
int x,y,h;
}a[2510];
int chk[40010],t,ans;
int main(){
int i,n,k,x,y;
scanf("%d",&n);
for(i=1,n/=2;i<=n;++i)scanf("%d%d%d%d",&x,&y,&a[i].x,&a[i].y);
scanf("%d",&k);
for(i=1;i<=k;++i)scanf("%d%d%d%d",&x,&y,&y,&y),chk[x]=1;
for(i=1;i<=n;++i)a[i].h=chk[a[i].x];
for(i=1;i<=n;++i){
x=a[i].x;
while(t&&a[t].y>a[i].y){
if(a[t-1].y>=a[i].y){
if(a[t].h)a[t-1].h=1;
else ans+=(a[i].x-a[t].x)*(a[t].y-a[t-1].y);
}
else{
if(a[t].h)a[i].h=1;
else ans+=(a[i].x-a[t].x)*(a[t].y-a[i].y);
a[i].x=a[t].x;
}
--t;
}
if(a[t].y==a[i].y)a[t].h|=a[i].h;
else a[++t]=a[i];
}
printf("%d",ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |