QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 50

#15375. 押韵

统计

在克罗地亚语课上,Jakov 正在阅读一首由 $n$ 行组成的诗,这首诗包含 $n/4$ 个诗节(stanza)。第 1, 2, 3, 4 行为第一个诗节,第 5, 6, 7, 8 行为第二个诗节,依此类推。每个诗节中的每行都恰好由 $m$ 个单词组成。

我们称两行诗押韵,当且仅当它们最后一个单词的最后 $k$ 个字母完全相同。如果某行诗的最后一个单词的长度小于 $k$ 个字母,则该行诗不与任何诗行押韵。

在诗节层面上,我们区分以下三种押韵格式:

  • AABB —— 第 1 行和第 2 行押韵,且第 3 行和第 4 行押韵
  • ABAB —— 第 1 行和第 3 行押韵,且第 2 行和第 4 行押韵
  • ABBA —— 第 1 行和第 4 行押韵,且第 2 行和第 3 行押韵

(注意:这里的第 1, 2, 3, 4 行指的是该诗节内部的相对行数。)

老师要求 Jakov 确定在这首诗中,这三种押韵格式各在多少个诗节中出现。请帮助 Jakov 正确回答老师的问题,并在克罗地亚语课上拿到 A!

输入格式

第一行包含自然数 $n, m$ 和 $k$($1 \le n \le 500$ 且 $n$ 是 $4$ 的倍数,$1 \le m, k \le 20$)。

接下来的 $n$ 行,每行包含 $m$ 个单词,每个单词最多由 20 个英文小写字母组成。

输出格式

在第一行也是唯一的一行中,输出三个整数,分别代表:出现 AABB 押韵格式的诗节数量、出现 ABAB 押韵格式的诗节数量,以及出现 ABBA 押韵格式的诗节数量。

子任务

子任务 分值 约束条件
1 15 $n = 4$
2 15 每个单词仅由 1 个字符组成。
3 20 无附加限制。

样例

输入样例 1

8 2 3
aa bb
cc bb
dd ee
ff ee
auu aaaaaahh
auu wer
asdf power
lol kldahh

输出样例 1

0 0 1

输入样例 2

8 2 2
ja programiram
mjesec listopad
ponekad chillam
voda vodopad
banana jabuka
fiziku znam
teska odluka
njam njam

输出样例 2

0 2 0

输入样例 3

4 4 2
pas konj zec macka
trokut teziste poluravnina tocka
nogomet tenis ragbi odbojka
sir mlijeko kulen sunka

输出样例 3

1 1 1

说明

样例 1 说明:在第一个诗节中,没有任何两行可以押韵,因为每个最后一个单词都只有 2 个字母,而 $k = 3$。第二个诗节符合 ABBA 押韵格式,因为第 1 行和第 4 行押韵(aaaaaahhkldahh),且第 2 行和第 3 行也押韵(werpower)。因此,AABB 和 ABAB 押韵格式出现 0 次,而 ABBA 押韵格式出现 1 次。

样例 3 说明:在这首诗唯一的诗节中,每行最后一个单词的最后两个字母都是 ka,因此所有行都互相押韵。由此可知,这一个诗节同时符合所有三种押韵格式:AABB、ABAB 和 ABBA。

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.