【Codeforces Round #369 (Div. 2)】Codeforces 711A Bus to Udayland

原创 2016年08月30日 13:53:09

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?
Input

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. 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 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.

模拟。

#include<cstdio>
#include<cstring>
char s[1010][10];
int main()
{
    int i,j,k,m,n,p,q,x,y,z;
    bool flag;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
      scanf("%s",s[i]+1);
    flag=0;
    for (i=1;i<=n;i++)
    {
        if (s[i][1]=='O'&&s[i][2]=='O')
        {
            s[i][1]=s[i][2]='+';
            flag=1;
            break;
        }
        if (s[i][4]=='O'&&s[i][5]=='O')
        {
            s[i][4]=s[i][5]='+';
            flag=1;
            break;
        }
    }
    if (!flag) printf("NO\n");
    else
    {
        printf("YES\n");
        for (i=1;i<=n;i++)
          printf("%s\n",s[i]+1);
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载,欢迎添加友链。

相关文章推荐

Codeforces Round #369 (Div. 2) A. Bus to Udayland

codeforces ACM 模拟

Codeforces Round #369 (Div. 2) A. Bus to Udayland【模拟】

题意:公共汽车座位,每一排有四个座位,中间的 '|' 代表过道,'O' 代表空位置,'X' 代表有人座,问你能否找到两个连在一起的座位(中间有过道不算),如果可以的话吧相应的符号变为 '+'。 简单模...

【模拟】Codeforces 711A Bus to Udayland

题目链接:   http://codeforces.com/problemset/problem/711/A 题目大意:   N个字符串,每个字符串5位,找到第一个出现两个OO的...

codeforces——711A—— Bus to Udayland

A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes inpu...

Codeforces 711A- Bus to Udayland

A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes ...

Codeforces Problem 711A Bus to Udayland(brute force+implementation)

Codeforces Problem 711A Bus to Udayland(brute force+implementation)

【Codeforces Round #369 (Div. 2)】Codeforces 711C Coloring Trees

动态规划

Codeforces Round #369 (div.2) 即 Codeforces 711

CodeForces Round #369 (div.2) DescreptionA有N排座位,每排有4个,这4个被分成了两组。给出每个座位是否是空的,问是否有相邻的座位。B给你一个N * N的幻方,...

Codeforces 711 E. ZS and The Birthday Paradox(数学)——Codeforces Round #369 (Div. 2)

[传送门](http://codeforces.com/contest/711/problem/E) E. ZS and The Birthday Paradoxtime limit per test...

【Codeforces Round #369 (Div. 2)】Codeforces 711B Chris and Magic Square

模拟
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)