You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB
C++

#include <bits/stdc++.h>
using namespace std;
int seat[1111][1111];
int main()
{
int T, R, S, B;
scanf("%d", &T);
for (int t = 1; t <= T; t++)
{
memset(seat, 0, sizeof(seat));
scanf("%d%d%d", &R, &S, &B);
for (int i = 0, r, b; i < B; i++)
{
scanf("%d%d", &r, &b);
seat[r][b] = -1;
}
for (int i = 0; i < R; i++) seat[i][S] = -1;
int ans1 = 0, ans2 = 0;
for (int i = 0; i < R; i++)
for (int j = 0; j < S; j++)
{
if (seat[i][j] == -1) continue;
seat[i][j++] = 1;
}
for (int i = 0; i < R; i++)
for (int j = 0; j < S; j++)
{
//printf("%2d %c", seat[i][j], " \n"[j == S - 1]);
if (seat[i][j] == 1)
ans1++, seat[i][j] = 0;
}
for (int i = 0; i < R; i++)
for (int j = 0; j < S; j++)
{
if (seat[i][j] == -1) continue;
if (seat[i][j + 1] == -1 && (j == 0 || seat[i][j - 1] != 1))
{
seat[i][j] = 1;
continue;
}
j++;
seat[i][j] = 1;
j++;
}
for (int i = 0; i < R; i++)
for (int j = 0; j < S; j++)
{
//printf("%2d %c", seat[i][j], " \n"[j == S - 1]);
if (seat[i][j] == 1)
ans2++, seat[i][j] = 0;
}
printf("Case #%d: %d %d\n", t, ans1, ans2);
}
return 0;
}