Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int m[505][505],ans,w,h,n,x1,x2,y1,y2;
- int main()
- {
- while (1)
- {
- ans=0;
- for (int i=1; i<=500; i++)
- for(int j=1; j<=500; j++)
- m[i][j]=-1;
- scanf("%d %d %d",&w,&h,&n);
- for (int i=1; i<=w; i++)
- for(int j=1; j<=h; j++)
- m[i][j]=0;
- if (w==0 && h==0 && n==0)
- break;
- for (int k=0; k<n; k++)
- {
- scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
- if (x1>x2)swap(x1,x2);
- if (y1>y2)swap(y1,y2);
- for (int i=x1; i<=x2; i++)
- for (int j=y1; j<=y2; j++)
- m[i][j]=1;
- }
- for (int i=1; i<=500; i++)
- {
- for(int j=1; j<=500; j++)
- {
- if (m[i][j]==0)
- ans++;
- }
- }
- if (ans==0)
- printf("There is no empty spots.\n");
- else if (ans==1)
- printf("There is one empty spot.\n");
- else if (ans!=0 && ans!=1)
- printf("There are %d empty spots.\n",ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement