QOJ.ac

QOJ

Time Limit: 15.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#11010. 玩 SET 游戏

Statistics

SET 是一款由 Marsha Falco 于 1974 年设计,并由 Set Enterprises 于 1991 年发行的实时卡牌游戏。牌堆由 81 张独特的卡牌组成,每张卡牌有四个特征,每个特征有三种可能性:形状数量(一、二或三)、形状(菱形、波浪形、椭圆形)、阴影(实心、条纹或空心)以及颜色(红色、绿色或紫色)。每种特征组合(例如一张 [three][striped][green][diamonds] 的卡牌)在牌堆中恰好出现一次。

在游戏中,某些三张卡牌的组合被称为一个“集合”(set)。对于四个特征类别中的每一个——颜色、数量、形状和阴影——这三张卡牌在该特征上必须满足:a) 全部相同,或 b) 全部不同。换句话说:对于每个特征,这三张卡牌不能出现两张卡牌显示该特征的一种版本,而剩下的一张卡牌显示另一种版本的情况。

例如: [three][solid][red][diamonds] [two][solid][green][squiggles] [one][solid][purple][oval]

这三张牌构成一个集合,因为这三张牌的阴影完全相同,而它们的数量、颜色和形状各不相同。

给定 $N$ 张独特的卡牌,你需要将它们组成集合。你需要输出在给定卡牌下能构成的最大集合数量,且每张卡牌最多只能使用一次。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例包含一行,为一个整数 $N$。接下来的 $N$ 行中,第 $i$ 行描述第 $i$ 张卡牌。它包含四个特征类别,格式为 [*][*][*][*]

没有重复的卡牌。

$1 \le T \le 100$。 $1 \le N \le 38$。 其中最多有 10 个测试用例满足 $N > 35$。

输出格式

对于每个测试用例,第一行打印 Case #x: y,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是最大集合数量。然后打印 $y$ 行,每行包含三个整数 $id1, id2, id3$,定义了构成一个集合的卡牌索引(从 1 开始)。如果存在多种方案,输出其中任意一种即可。

样例

输入 1

1
7
[one][diamond][solid][red]
[two][diamond][solid][red]
[three][diamond][solid][red]
[one][diamond][solid][green]
[one][diamond][solid][purple]
[two][diamond][solid][purple]
[purple][three][diamond][solid]

输出 1

Case #1: 2
1 2 3
5 6 7

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.