#P11796. Pointing Emoticons

    ID: 13893 Type: Default 1000ms 256MiB

Pointing Emoticons

Pointing Emoticons

A group chat has n distinct members and exactly n messages sent in order. The i-th message is sent by the i-th person and contains one emoticon with a label ai (where \(0 \le a_i \le 2\)). There are three types of emoticons:

  • Emoticon labeled \(0\) points to the sender of the next message (i.e. message \(i+1\)), if it exists.
  • Emoticon labeled \(1\) points to the sender of the previous message (i.e. message \(i-1\)), if it exists.
  • Emoticons labeled \(2\) do not point to anyone.

A member is called a "naipi" if and only if at least one message from another member points to them. Given the sequence \(a_1, a_2, \ldots, a_n\) and an integer \(k\) \(1 \le k \le n\), determine whether the \(k\)-th person is a naipi.

Note: Since each message is sent by a different person, a message does not point to its own sender.

inputFormat

The first line contains two integers \(n\) and \(k\) separated by a space, where \(n\) is the number of messages and \(k\) is the person to be checked.

The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\) separated by spaces. Each \(a_i\) satisfies \(0 \le a_i \le 2\).

outputFormat

Output a single line containing YES if the \(k\)-th person is pointed to at least once by another message, or NO otherwise.

sample

5 1
2 1 2 0 2
YES