CF1761A.Two Permutations

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given three integers nn, aa, and bb. Determine if there exist two permutations pp and qq of length nn, for which the following conditions hold:

  • The length of the longest common prefix of pp and qq is aa.
  • The length of the longest common suffix of pp and qq is bb.

A permutation of length nn is an array containing each integer from 11 to nn exactly once. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array), and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

给你三个整数 nn、aa 和 bb。判断是否存在两个长度为 nn 的排列 pp 和 qq,使得以下条件成立:

  • pp 和 qq 的最长公共前缀长度为 aa;
  • pp 和 qq 的最长公共后缀长度为 bb。

长度为 nn 的排列是指恰好包含从 11 到 nn 的每个整数各一次的数组。例如,[2,3,1,5,4][2,3,1,5,4] 是一个排列,但 [1,2,2][1,2,2] 不是排列(数字 22 在数组中出现了两次),[1,3,4][1,3,4] 也不是排列(此时 n=3n=3,但数组中包含了 44)。

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041\leq t\leq 10^4) — the number of test cases. The description of test cases follows.

The only line of each test case contains three integers nn, aa, and bb (1≤a,b≤n≤1001\leq a,b\leq n\leq 100).

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1041\leq t\leq 10^4)—— 测试用例的数量。随后是各测试用例的描述。

每个测试用例仅有一行,包含三个整数 nn、aa 和 bb(1≤a,b≤n≤1001\leq a,b\leq n\leq 100)。

输出格式

For each test case, if such a pair of permutations exists, output "Yes"; otherwise, output "No". You can output each letter in any case (upper or lower).

对于每个测试用例,如果存在这样的一对排列,则输出“Yes”;否则输出“No”。你可以以任意大小写(大写或小写)输出每个字母。

输入输出样例

  • 输入#1

    4
    1 1 1
    2 1 2
    3 1 1
    4 1 1

    输出#1

    Yes
    No
    No
    Yes

说明/提示

In the first test case, [1][1] and [1][1] form a valid pair.

In the second test case and the third case, we can show that such a pair of permutations doesn't exist.

In the fourth test case, [1,2,3,4][1,2,3,4] and [1,3,2,4][1,3,2,4] form a valid pair.

在第一个测试用例中,[1][1] 和 [1][1] 构成一对有效排列。

在第二个和第三个测试用例中,我们可以证明这样的排列对不存在。

在第四个测试用例中,[1,2,3,4][1,2,3,4] 和 [1,3,2,4][1,3,2,4] 构成一对有效排列。

输入解题思路,AI测评打分。不知道怎么写?

首页