// UVa 10703 - Free spots
#include <iostream>
#include <string.h>
using namespace std;
int main() {
int w, h, n;
cin >> w >> h >> n;
while (w || h || n) {
bool mat[501][501];
memset(mat, true, sizeof(mat));
for (int i = 0; i < n; i++) {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2) {
int c = x1;
x1 = x2;
x2 = c;
}
if (y1 > y2) {
int c = y1;
y1 = y2;
y2 = c;
}
for (int x = x1; x <= x2; x++)
for (int y = y1; y <= y2; y++)
mat[x][y] = false;
}
unsigned long long sol = 0;
for (int x = 1; x <= w; x++)
for (int y = 1; y <= h; y++)
if (mat[x][y])
sol++;
switch (sol) {
case 0:
cout << "There is no empty spots." << endl;
break;
case 1:
cout << "There is one empty spot." << endl;
break;
default:
cout << "There are " << sol << " empty spots." << endl;
}
cin >> w >> h >> n;
}
return 0;
}
Tuesday, September 15, 2015
UVa 10703 - Free spots
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment