Untitled

unknown
plain_text
a month ago
2.0 kB
1
Indexable
Never
```#include <bits/stdc++.h>

using namespace std;

using ll = long long;
double pi = 3.14159265358979323846;
const int MOD = 1e9 + 7;
#define TIME    cout << "time taken : " << (float)clock() * 1000 / CLOCKS_PER_SEC << "ms" << endl;
#define endl '\n'

int main() {
// freopen("mex.in","r",stdin);

//  =============================================================================
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
//  =============================================================================

while (true)
{
int w , h , n;
cin >> w >> h >> n;
if(n == 0 && h == 0 && w == 0 )
break;

vector<vector<int>>v(w + 2 , vector<int>(h + 2));
while (n--)
{
int x_1 , y_1 , x_2 , y_2;
cin >> x_1 >> y_1 >> x_2 >> y_2;
int x1 = min(x_1 , x_2);
int y1 = min(y_1 , y_2);
int x2 = max(x_1 , x_2);
int y2 = max(y_1 , y_2);

v[x1][y1]++;
v[x2 + 1][y2 + 1]++;
v[x2 + 1][y1]--;
v[x1][y2 + 1]--;

}
for(int i = 1;i <= w;++i)
for(int j = 1;j <= h;++j)
v[i][j] +=v[i][j-1];
for(int i = 1;i <= h;++i)
for(int j = 1;j <= w;++j)
v[j][i] +=v[j-1][i];

ll ans = 0;
for(int i = 1;i <= w;++i)
for(int j = 1;j <= h;++j)
if(v[i][j] == 0)
ans++;

if(ans == 0)
cout << "There is no empty spots." << endl;
else if(ans == 1)
cout << "There is one empty spot." << endl;
else
cout << "There are " << ans << " empty spots." << endl;

}

}

```