#C325. Spiral Bitonic Subarray Existence

    ID: 46656 Type: Default 1000ms 256MiB

Spiral Bitonic Subarray Existence

Spiral Bitonic Subarray Existence

You are given two positive integers M and N representing the dimensions of a matrix. The matrix is filled by traversing in a spiral order with consecutive integers from 1 to M \times N. Your task is to determine whether there exists a contiguous subarray (with at least three elements) obtained from the spiral order traversal that forms a bitonic sequence. A sequence is said to be bitonic if it first strictly increases and then strictly decreases. In mathematical notation, a sequence \(a_1, a_2, \ldots, a_k\) is bitonic if there exists an index \(i\) with \(1 < i < k\) such that \[ a_1 < a_2 < \cdots a_{i+1} > \cdots > a_k. \]

For the purpose of this problem, you only need to determine if there exists at least one contiguous subarray from the spiral order traversal that can form a bitonic sequence. Note that if the total number of elements is less than 3, then it is not possible to form such a sequence.

inputFormat

The input consists of a single line containing two space-separated integers M and N (1 ≤ M, N ≤ 10^5), representing the dimensions of the matrix.

outputFormat

Output a single line with the string YES if there exists a contiguous subarray (of length at least 3) from the spiral order traversal that forms a bitonic sequence; otherwise, output NO.

## sample
1 1
NO