No.85 TV Zapping (1)
タグ : / 解いたユーザー数 311
作問者 : 👑
kmjp
Problem Statement
The TV remote control that yuki-kun owns has a total of \(N\times M\) buttons arranged in a rectangle of \(N\) rows and \(M\) columns.
Pressing the button in row \(X\), column \(Y\) of the remote lets him watch channel \(((X-1) \times M + Y)\) on the TV.
(A concrete example is given in the explanation of Sample Case 1.)
yuki-kun has just pressed the button for channel \(C\) and is still watching channel C.
However, partway through he came to want to take a look at the content of all the other channels.
In order to quickly tour all the channels and return to the original channel \(C\), yuki-kun presses buttons in order according to the following rules.
- The first button he presses is a button vertically or horizontally adjacent to the button for channel \(C\) that he just pressed.
- After that, he keeps pressing a button vertically or horizontally adjacent to the button he pressed immediately before.
- After pressing the button of every channel other than channel \(C\) exactly once each, he finally presses the button for channel \(C\) again.
Input
N M C
\(1 \le N, M \le 100\)
\(1 \le C \le N\times M \)
At least one of \(N\) and \(M\) is at least 2.
That is, there is at least one button other than the one for channel \(C\).
Output
Print "YES" if there exists an order of pressing the buttons that satisfies the conditions, and "NO" otherwise.
Print a newline at the end.
Sample
Sample 1
Input
4 3 5
Output
YESAs an example, as shown below, starting from channel 5 and going around 4→1→2→3→6→9→12→11→10→7→8→5, he can watch all the channels and return to the original channel 5.
Sample 2
Input
3 3 1
Output
NO
Sample 3
Input
12 34 56
Output
YES
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。