No.1366 Swap Kadomatsu Sequence: Ume
Definition
When a sequence $v = (a_1,a_2,a_3)$ consisting of three elements satisfies the following conditions, $v$ is said, according to tradition, to be a Kadomatsu sequence.
- $a_1,a_2,a_3$ are all distinct
- Among the three elements, $a_2$ is the largest or the smallest
Problem Statement
You are given two sequences, each consisting of three elements.
Perform the following operation exactly once. Not performing the operation at all is not allowed.
- Choose one element from one sequence and one element from the other sequence, and swap those elements.
You may choose the same number.
Can both sequences be made Kadomatsu sequences after the operation?
Print Yes if it is possible, and No otherwise.
Input
$a_1\ a_2\ a_3$ $b_1\ b_2\ b_3$
$1 \le a_i, b_i \le 9$
All values in the input are integers.
Output
Print Yes if both sequences can be made Kadomatsu sequences, and No if this is impossible.
Sample
Sample 1
Input
4 5 6 1 2 3
Output
Yes
For example, swap 5 and 2. Then the first sequence becomes 4 2 6 and the second sequence becomes 1 5 3, and both of them are Kadomatsu sequences.
Sample 2
Input
3 4 5 3 5 4
Output
No
You cannot swap within the same sequence.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。