ahamed210

free_spots

Nov 10th, 2021
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int l;
  4. typedef long long int ll;
  5. #define loop(a, b) for(int i = a; i < b; i++)
  6. #define PI acos(-1.0)
  7. const ll INF = LLONG_MAX;
  8.  
  9. const ll mod = 1000000007;
  10. ll gcd(ll a,ll b){ if(b == 0) return a; return gcd(b, a % b); }
  11.  ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  12. //ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a)%mod;b>>=1;a = (a*a)%mod;}return res%mod;}
  13. //leftmost set bit
  14. l clz(int N) {return N ? 32 - __builtin_clz(N) : -(1e9+1);}
  15. //ll clz(unsigned long long N){return N ? 64 - __builtin_clzll(N) : -(1e18+1);}
  16. ll setbit(ll x){return __builtin_popcountll(x);}
  17. ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a);b>>=1;a = (a*a);}return res;}
  18. bool arraySortedOrNot(int arr[], int n){if (n == 0 || n == 1) return true;for (int i = 1; i < n; i++)if (arr[i - 1] > arr[i]) return false;return true;}
  19. // long long v[400002];
  20. // void Quicksort(int begin,int end){
  21. //   int e,b,aux,p;b=begin;e=end;p=v[(e+b)/2];
  22. //   while(v[b]<p){b++;}while(v[e]>p){e--;}while(b<e){aux=v[b];v[b]=v[e];v[e]=aux;do{b++;}while(v[b]<p);
  23. //   do{e--;}while(v[e]>p);}if(begin<e){ Quicksort(begin,e);}
  24. //   if(e+1<end){ Quicksort(e+1,end);}
  25. // }
  26.  
  27. void run(){
  28.     ios::sync_with_stdio(false);
  29.     cin.tie(NULL);
  30.     cout.tie(NULL);
  31. #ifndef ONLINE_JUDGE
  32.     freopen("input.txt", "r", stdin);
  33.     freopen("output7.txt", "w", stdout);
  34. #else
  35. #endif
  36. }
  37.  
  38. void solve(l a, l b, l c){
  39.     bool ara[a+1][b+1];
  40.     memset(ara, true, sizeof(ara));
  41.     while(c--){
  42.         l x1, y1, x2, y2;cin>>x1>>y1>>x2>>y2;
  43.         if(x1 > x2) swap(x1,x2);
  44.         if(y1 > y2) swap(y1,y2);
  45.         for(l i = x1; i <= x2; i++){
  46.             for(l j = y1; j <= y2; j++){
  47.                 ara[i][j] = false;
  48.             }
  49.         }
  50.     }
  51.  
  52.      ll cnt = 0;
  53.     for(l i = 1; i <= a; i++){
  54.         for(l j = 1; j <= b; j++){
  55.             if(ara[i][j]) cnt++;
  56.         }
  57.     }
  58.     if(cnt==0) cout << "There is no empty spots." << endl;
  59.     else if(cnt == 1) cout << "There is one empty spot." << endl;
  60.     else cout << "There are " << cnt << " empty spots." << endl;
  61. }
  62.  
  63. int main()
  64. {
  65.     //clock_t tStart = clock();
  66.     ios::sync_with_stdio(false);
  67.     cin.tie(NULL);
  68.     cout.tie(NULL);
  69.     //run();
  70.     //l n = 1;cin>>n;
  71.     //dummy getline
  72.     //string s;getline(cin,s);
  73.     //char s[2100];
  74.     //while(cin>>s) {solve(s);}
  75.     //while(n--){solve();}
  76.     l a,b,c;
  77.     while(cin>>a>>b>>c && a+b+c){solve(a,b,c);}
  78.     //cout << endl;
  79.     //printf("Time taken: %.10fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment