CF1761A.Two Permutations
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three integers n, a, and b. Determine if there exist two permutations p and q of length n, for which the following conditions hold:
- The length of the longest common prefix of p and q is a.
- The length of the longest common suffix of p and q is b.
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).
给你三个整数 n、a 和 b。判断是否存在两个长度为 n 的排列 p 和 q,使得以下条件成立:
- p 和 q 的最长公共前缀长度为 a;
- p 和 q 的最长公共后缀长度为 b。
长度为 n 的排列是指恰好包含从 1 到 n 的每个整数各一次的数组。例如,[2,3,1,5,4] 是一个排列,但 [1,2,2] 不是排列(数字 2 在数组中出现了两次),[1,3,4] 也不是排列(此时 n=3,但数组中包含了 4)。
输入格式
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤104) — the number of test cases. The description of test cases follows.
The only line of each test case contains three integers n, a, and b (1≤a,b≤n≤100).
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。随后是各测试用例的描述。
每个测试用例仅有一行,包含三个整数 n、a 和 b(1≤a,b≤n≤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] and [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] and [1,3,2,4] form a valid pair.
在第一个测试用例中,[1] 和 [1] 构成一对有效排列。
在第二个和第三个测试用例中,我们可以证明这样的排列对不存在。
在第四个测试用例中,[1,2,3,4] 和 [1,3,2,4] 构成一对有效排列。
输入解题思路,AI测评打分。不知道怎么写?