竞争性编程问题的特殊输入问题?

时间:2021-06-16 21:01:49

标签: python input

我目前正在致力于在 HackerRank (https://www.hackerrank.com/challenges/constructing-a-number/problem) 上构造一个数字,并且我遇到了某种类型的输入:

3
1
9
3
40 50 90
2
1 4

显然,这 7 行输入中有 3 个测试用例。有人能解释一下为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

引用 Input Format 部分:

<块引用>

第一行包含一个整数 t,表示查询的数量。以下几行描述了查询。每个查询都用两行描述。这些行中的第一行包含一个整数 n。第二个包含空格分隔的整数 a1、a2、...、an。

因此,第一个数字表示您需要预期的查询数量,但实际查询是成对的:一对中的第一行有一个整数,同一对中的第二行有一个整数列表。这样的对只是重复。我相信您对整数列表的长度不一定是常数这一事实感到困惑。

在您的评论示例中:

3 // How many of the queries?

// 1st query:
1 // Integer
9 // List of integers

// 2nd query:
3 // Integer
40 50 90 // List of integers

// 3rd query:
2 // Integer
1 4 // List of integers