問題一覧 > 通常問題

No.85 TV Zapping (1)

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 311
作問者 : 👑 kmjp
お気に入りにしたユーザー ProblemId : 156 / 自分の提出
問題文最終更新日: 2026-06-26 16:16:14
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 61 (順位表) の他の問題:

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.
Given \(N\), \(M\), \(C\), determine whether there exists an order of pressing the buttons that satisfies all of the above rules.

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
YES
As 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もしくは右上の雲マークをクリックしてアカウントを作成してください。