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