2 consecutive seats on the train

Link: https://www.nowcoder.com/acm/contest/118/G
Source: Niuke.com

Time limit: C/C++ 1 second, other languages ​​2 seconds
Space limit: C/C++ 32768K, other languages ​​65536K
64bit IO Format: %lld

Topic description


Programmers A and B are going to take a train together, there are 4 seats in each row on this train, and the four seats
Divided in half by the aisle. When A and B got to the car, some seats were already occupied.
A and B are good friends, so they want to find a pair of seats that are connected together. Two joined seats are two seats in the same row but not separated by an aisle. Given the number of seats on a train, can you find a pair of consecutive seats?

Enter description:

The first line of each group of samples is an integer n, 1<=n<=1000, indicating that the train has a total of n rows of seats.
Each of the next n lines contains a string of five characters, and the five characters of the i-th string represent the situation of the i-th row of seats. The third character of each string is the character '|', which represents the aisle, and each other character represents the occupancy of a seat. The character 'O' indicates that the seat is empty, and the character 'X' indicates that the seat is already occupied, that is, it is occupied.

Output description:

If you can find a set of joints, first output a line of string "YES" (do not output quotation marks) in the first line, in the next n
The seats of the output car, except that the seats of A and B are represented by the character '+', the rest of the output format is consistent with the seats of the car in the input format.
If you can't find a set of connectors, just print a line of "NO" (no quotes).
When there are multiple sets of seating arrangements, place A and B in the front row. If there are two sets of feasible solutions in the same row, choose to place A and B on the left.
For example, in the case of a group of cars, it should be arranged to the right of the arrow.
OO | OO -> ++ | OO
OO | OO -> OO | OO

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325702888&siteId=291194637