#abc327d. D - Good Tuple Problem
D - Good Tuple Problem
Score : points
问题描述
一对长度为 的由不超过 的正整数组成的序列,记作 $(S, T) = ((S_1, S_2, \dots, S_M), (T_1, T_2, \dots, T_M))$,如果满足以下条件,则称其为 一对良好的序列。
- 存在一个由 和 组成的长度为 的序列 ,满足以下条件:
- 对于每个 ,有 。
现给定一个由不超过 的正整数组成的长度为 的序列对:$(A, B) = ((A_1, A_2, \dots, A_M), (B_1, B_2, \dots, B_M))$。若 是一对良好的序列,则输出 Yes
;否则,输出 No
。
约束条件
- )
- 所有输入值均为整数。
输入格式
输入通过标准输入给出,格式如下:
N M
A_1 A_2 ... A_M
B_1 B_2 ... B_M
输出格式
如果 ((A, B)) 是一个好的序列对,输出 Yes
;否则,输出 No
。
样例输入 1
3 2
1 2
2 3
样例输出 1
Yes
如果设置 ( X = (0, 1, 0) ),那么 ( X ) 是一个长度为 ( N ) 的由 0 和 1 组成的序列,且满足 ( ) 和 ( )。
因此,((A, B)) 满足好的序列对的条件。
样例输入 2
3 3
1 2 3
2 3 1
样例输出 2
No
不存在满足条件的序列 ( X ),因此 ((A, B)) 不是一个好的序列对。
样例输入 3
10 1
1
1
样例输出 3
No
样例输入 4
7 8
1 6 2 7 5 4 2 2
3 2 7 2 1 2 3 3
样例输出 4
Yes
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
A pair of sequences of length consisting of positive integers at most , $(S, T) = ((S_1, S_2, \dots, S_M), (T_1, T_2, \dots, T_M))$, is said to be a good pair of sequences when satisfies the following condition.
- There exists a sequence of length consisting of and that satisfies the following condition:
- for each .
You are given a pair of sequences of length consisting of positive integers at most : $(A, B) = ((A_1, A_2, \dots, A_M), (B_1, B_2, \dots, B_M))$. If is a good pair of sequences, print Yes
; otherwise, print No
.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If is a good pair of sequences, print Yes
; otherwise, print No
.
Sample Input 1
3 2
1 2
2 3
Sample Output 1
Yes
If we set , then is a sequence of length consisting of and that satisfies and .
Thus, satisfies the condition of being a good pair of sequences.
Sample Input 2
3 3
1 2 3
2 3 1
Sample Output 2
No
No sequence satisfies the condition, so is not a good pair of sequences.
Sample Input 3
10 1
1
1
Sample Output 3
No
Sample Input 4
7 8
1 6 2 7 5 4 2 2
3 2 7 2 1 2 3 3
Sample Output 4
Yes
update @ 2024/3/10 01:51:10