QOJ.ac

QOJ

Time Limit: 0.5 s Memory Limit: 256 MB Total points: 100

#11250. 11月11日

Statistics

今天是 11 月 11 日,也就是光棍节!在这一天,某电影院只允许单身人士观看电影。禁止情侣入场!

电影院共有 $R$ 排,编号为 $0, 1, \dots, R - 1$。每排有 $S$ 个座位,编号为 $0, 1, \dots, S - 1$。

单身人士拒绝坐在彼此相邻的位置。如果两个座位在同一排且座位编号连续,则认为这两个座位相邻。

电影院中共有 $B$ 个损坏的座位,任何人不能坐在损坏的座位上。

电影院老板请你计算以下两个值:

  • 电影院中最多能容纳的单身人士数量。
  • 为了使电影院无法再容纳更多单身人士,所需的最少单身人士数量。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。

每个测试用例以一个空行开始,然后是两个整数 $R$ 和 $S$,分别表示行数和每排的座位数。

下一行包含一个整数 $B$。随后有 $B$ 行,每行包含两个整数 $r_i$ 和 $s_i$,表示第 $r_i$ 排的第 $s_i$ 个座位是损坏的。所有损坏的座位各不相同。

输出格式

对于每个测试用例,输出一行 “Case #x: y z”,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是电影院中最多能容纳的单身人士数量,$z$ 是使电影院无法再容纳更多单身人士所需的最少单身人士数量。

数据范围

  • $1 \le T \le 100$
  • $1 \le R, S \le 1000$
  • $0 \le B \le 1000$
  • $0 \le r_i \le R - 1$
  • $0 \le s_i \le S - 1$

样例

输入 1

3

2 3
1
0 1

2 3
0

1 1
1
0 0

输出 1

Case #1: 4 3
Case #2: 4 2
Case #3: 0 0

说明

在样例 1 中,电影院最多可以容纳 4 名单身人士:

SBS
S.S

然而,3 名单身人士也可以占满电影院:

SBS
.S.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.