Advertisement
erfanul007

UVa 10703

Dec 9th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool taken[509][509];
  4.  
  5. int main()
  6. {
  7. int W, H, N;
  8. while (cin>>W>>H>>N,W){
  9. while (N--){
  10. int x1,y1,x2,y2;
  11. cin>>x1>>y1>>x2>>y2;
  12. if(x1>x2)
  13. swap(x1,x2);
  14. if (y1>y2)
  15. swap(y1,y2);
  16. for(int y=y1-1;y<y2;y++)
  17. for(int x=x1-1;x<x2;x++)
  18. taken[y][x]=true;
  19. }
  20. int cnt=0;
  21.  
  22. for (int y=0;y<H;y++){
  23. for (int x=0;x<W;x++){
  24. if (!taken[y][x])
  25. cnt++;
  26. else
  27. taken[y][x]=false;
  28. }
  29. }
  30. if (cnt==0)
  31. cout<<"There is no empty spots.\n";
  32. else if (cnt==1)
  33. cout<<"There is one empty spot.\n";
  34. else
  35. cout<<"There are "<<cnt<<" empty spots.\n";
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement