import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
while (true) {
StringTokenizer st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
int qu = Integer.parseInt(st.nextToken());
if (x == 0 && y == 0 && qu == 0) {
break;
}
boolean arr[][] = new boolean[x + 1][y + 1];
for (int c = 0; c < qu; c++) {
st = new StringTokenizer(br.readLine());
int x1 = Integer.parseInt(st.nextToken());
int y1 = Integer.parseInt(st.nextToken());
int x2 = Integer.parseInt(st.nextToken());
int y2 = Integer.parseInt(st.nextToken());
for (int i = Math.min(x1, x2); i < Math.max(x1, x2) + 1; i++) {
for (int j = Math.min(y1, y2); j < Math.max(y1, y2) + 1; j++) {
arr[i][j] = true;
}
}
}
int counter = 0;
for (int i = 1; i < x + 1; i++) {
for (int j = 1; j < y + 1; j++) {
if (!arr[i][j]) {
counter++;
}
}
}if(counter==0){
sb.append("There is no empty spots.\n");
}else if(counter==1){
sb.append("There is one empty spot.\n");
}else{
sb.append("There are ").append(counter).append(" empty spots.\n");
}
br.readLine();
}
System.out.print(sb);
}
}
No comments:
Post a Comment