Codeforces Round #369 (Div. 2) A~D
A. Bus to Udayland
time limit per test
memory limit per test
input
output
ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has nrows of seats. There are 4
ZS and Chris are good friends. They insist to get a pair of neighbouring empty seats. Two seats are considered neighbouring if they are in the same row and in the same pair. Given the configuration of the bus, can you help ZS and Chris determine where they should sit?
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 1000)
Then, n lines follow. Each line contains exactly 5
Each character, except the walkway, equals to 'O' or to 'X'. 'O' denotes an empty seat, 'X' denotes an occupied seat. See the sample cases for more details.
Output
If it is possible for Chris and ZS to sit at neighbouring empty seats, print "YES" (without quotes) in the first line. In the next n
If there is no pair of seats for Chris and ZS, print "NO" (without quotes) in a single line.
If there are multiple solutions, you may print any of them.
Examples
input
6OO|OXXO|XXOX|OOXX|OXOO|OOOO|XX
output
YES++|OXXO|XXOX|OOXX|OXOO|OOOO|XX
input
4XO|OXXO|XXOX|OXXX|OX
output
NO
input
5XX|XXXX|XXXO|OXXO|OOOX|XO
output
YESXX|XXXX|XXXO|OXXO|++OX|XO
Note
Note that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.
O+|+X
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
题解:ZS和Chris坐bus去旅游,要上车啦。(滴滴。。学生卡。。)规定他们两个人一定要坐在一起。如果最先找出的pair座位就坐下,就输出YES并标志为++。否则输出NO。复杂度O(n)。水题。
AC代码:
#pragma comment(linker, "/STACK:102400000,102400000")//#include#include #include #include #include #include #include #include
暂时没有评论,来抢沙发吧~