#K71237. Can Rearrange Seats

    ID: 33487 Type: Default 1000ms 256MiB

Can Rearrange Seats

Can Rearrange Seats

Phoebe is organizing a music concert and needs to arrange the seats in a single row. The row is represented as a string of characters where each character can be:

  • R for a reserved seat,
  • . for an empty seat,
  • A for an aisle.

Due to visibility requirements, there cannot be more than \(X\) continuous empty seats between any two reserved seats after rearrangement.

Two rearrangements operations are allowed:

  1. Swapping an adjacent reserved seat with an empty seat.
  2. Splitting a continuous block of empty seats by inserting an aisle (A) between them.

Your task is to determine if it is possible to rearrange the seats such that no segment of continuous empty seats exceeds the limit of \(X\).

Note: Even though certain adjustments are allowed, the necessary and sufficient condition reduces to checking that the original arrangement does not contain any segment of . of length greater than \(X\) when considering the positions that are not empty.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains two space-separated integers: n (the number of seats) and X (the maximum allowed number of continuous empty seats).
  • The second line is a string of length n representing the seating arrangement. The string contains only the characters R, ., and A.

Note: Although n is provided, you can assume that the length of the seating arrangement is exactly n.

outputFormat

Output a single line to standard output containing YES if the seating arrangement can be rearranged to satisfy the visibility constraint, or NO otherwise.

## sample
10 3
..R...R.A.
YES