Submission #16243

#TimeUsernameProblemLanguageResultExecution timeMemory
16243eaststar수족관 1 (KOI13_aqua1)C++14
100 / 100
2 ms1268 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...