1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #define INF 1000000 using namespace std; void swp(int *p,int *q) { int tmp; tmp=*p; *p=*q; *q=tmp; } int main() { int h,w,n; int a,b,c,d; bool gr[505][505]; while(cin>>h) { cin>>w>>n; if(h+w+n==0) break; memset(gr,0,sizeof(gr)); int cnt=0; for(int k=0;k<n;k++) { cin>>a>>b>>c>>d; if(a>c) swp(&a,&c); if(b>d) swp(&b,&d); for(int i=a;i<=c;i++) { for(int j=b;j<=d;j++) { if(gr[i][j]==0) { cnt+=1; gr[i][j]=1; } } } } int ans = h*w-cnt; if(ans==0) cout<<"There is no empty spots.\n"; else if(ans==1) cout<<"There is one empty spot.\n"; else cout<<"There are "<<ans<<" empty spots.\n"; } return 0; } |