Advertisement
Saleh127

Untitled

Apr 24th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int x1,x2,y1,y2,i,j,w,h,n,k,l;
  6. while(scanf("%d %d %d",&w,&h,&n))
  7. {
  8. if(w==0 && h==0 && n==0) break;
  9.  
  10. int a[600][600]={0};
  11. long long f=0;
  12. while(n--)
  13. {
  14. scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  15. if(x1>x2)
  16. {
  17. swap(x1,x2);
  18. }
  19. if(y1>y2)
  20. {
  21. swap(y1,y2);
  22. }
  23. for(i=x1 ; i<=x2; i++)
  24. {
  25. for(j=y1; j<=y2; j++)
  26. {
  27. a[i][j]=1;
  28. }
  29. }
  30. }
  31. for(k=1; k<=w; k++)
  32. {
  33. for(l=1; l<=h; l++)
  34. {
  35. if(a[k][l]==0) f++;
  36. }
  37. }
  38. if(f==0)
  39. printf("There is no empty spots.\n");
  40. else if(f==1)
  41. printf("There is one empty spot.\n");
  42. else
  43. printf("There are %lld empty spots.\n",f);
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement