CF711A.Bus to Udayland

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.

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?

ZS 编码员和 Chris 猕猴正在前往乌代兰!为了抵达那里,他们必须乘坐特制的 IOI 巴士。该 IOI 巴士共有 nn 排座位,每排有 4 个座位,且座位被过道分成左右两对。当 ZS 和 Chris 到达时,巴士中已有部分座位被占用。

ZS 和 Chris 是好朋友,他们坚持要坐到一对相邻的空座位上。若两个座位位于同一排且属于同一对,则称它们是“相邻”的。给定巴士当前的座位布局,你能否帮助 ZS 和 Chris 确定他们应坐在哪里?

输入格式

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of rows of seats in the bus.

Then, n lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and the last two of them denote the second pair of seats in the row.

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.

输入的第一行包含一个整数 nn(1≤n≤10001 \leq n \leq 1000)—— 表示公交车中座位的行数。

接下来有 nn 行。每行恰好包含 5 个字符:前两个字符表示该行中的第一对座位,第三个字符表示过道(其值恒为 |),最后两个字符表示该行中的第二对座位。

除过道字符外,每个字符均为 'O' 或 'X':'O' 表示空座位,'X' 表示已被占用的座位。更多细节请参见样例。

输出格式

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 lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by exactly two charaters (they should be equal to 'O' in the input and to '+' in the output).

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.

如果克里斯和兹斯可以坐在相邻的空座位上,则在第一行输出 "YES"(不带引号)。接下来的 n 行中,输出公交车座位的配置,其中克里斯和兹斯所坐的一对座位上的字符被替换为 '+'。因此,输出的配置与输入配置恰好相差两个字符(这两个字符在输入中应为 'O',在输出中则为 '+')。

如果不存在这样一对可供克里斯和兹斯就坐的座位,则在单独一行中输出 "NO"(不带引号)。

如果存在多种可行解,你可以输出任意一种。

输入输出样例

  • 输入#1

    6
    OO|OX
    XO|XX
    OX|OO
    XX|OX
    OO|OO
    OO|XX

    输出#1

    YES
    ++|OX
    XO|XX
    OX|OO
    XX|OX
    OO|OO
    OO|XX
  • 输入#2

    4
    XO|OX
    XO|XX
    OX|OX
    XX|OX

    输出#2

    NO
  • 输入#3

    5
    XX|XX
    XX|XX
    XO|OX
    XO|OO
    OX|XO

    输出#3

    YES
    XX|XX
    XX|XX
    XO|OX
    XO|++
    OX|XO

说明/提示

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

注意,以下是对第一个样例情况的错误配置,因为座位必须位于同一对中。

O+|+X

XO|XX

OX|OO

XX|OX

OO|OO

OO|XX

输入解题思路,AI测评打分。不知道怎么写?

首页