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