关闭

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

标签: 模拟
103人阅读 评论(0) 收藏 举报
分类:

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);
    }
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:119641次
    • 积分:9414
    • 等级:
    • 排名:第1915名
    • 原创:857篇
    • 转载:3篇
    • 译文:0篇
    • 评论:45条
    联系方式
    QQ:1723010279
    邮箱:1723010279@qq.com
    欢迎交流。
    文章分类
    最新评论