309927: CF1761A. Two Permutations

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Two Permutations

题意翻译

给定 $n, a, b$,询问是否有满足最长公共前缀长度等于 $a$ 且最长公共后缀长度等于 $b$ 的两个排列存在。

题目描述

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).

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains a single integer $ t $ ( $ 1\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 $ n $ , $ a $ , and $ b $ ( $ 1\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).

输入输出样例

输入样例 #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.

Input

题意翻译

给定 $n, a, b$,询问是否有满足最长公共前缀长度等于 $a$ 且最长公共后缀长度等于 $b$ 的两个排列存在。

Output

题目大意:
给定三个整数n、a和b。需要判断是否存在两个长度为n的排列p和q,使得p和q的最长公共前缀长度为a,最长公共后缀长度为b。

输入输出数据格式:
输入格式:
每个测试包含多个测试案例。第一行包含一个整数t(1≤t≤10^4)——测试案例的数量。接下来是每个测试案例的描述。
每个测试案例只有一行,包含三个整数n、a和b(1≤a,b≤n≤100)。

输出格式:
对于每个测试案例,如果存在这样的排列对,输出"Yes";否则输出"No"。每个字母可以是大写或小写。

输入输出样例:
输入样例 #1
```
4
1 1 1
2 1 2
3 1 1
4 1 1
```
输出样例 #1
```
Yes
No
No
Yes
```
题目大意: 给定三个整数n、a和b。需要判断是否存在两个长度为n的排列p和q,使得p和q的最长公共前缀长度为a,最长公共后缀长度为b。 输入输出数据格式: 输入格式: 每个测试包含多个测试案例。第一行包含一个整数t(1≤t≤10^4)——测试案例的数量。接下来是每个测试案例的描述。 每个测试案例只有一行,包含三个整数n、a和b(1≤a,b≤n≤100)。 输出格式: 对于每个测试案例,如果存在这样的排列对,输出"Yes";否则输出"No"。每个字母可以是大写或小写。 输入输出样例: 输入样例 #1 ``` 4 1 1 1 2 1 2 3 1 1 4 1 1 ``` 输出样例 #1 ``` Yes No No Yes ```

加入题单

算法标签: