Codeforces 711A- Bus to Udayland
来源:互联网 发布:手机淘宝2015旧版本5.4 编辑:程序博客网 时间:2024/05/16 15:19
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 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?
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.
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.
6OO|OXXO|XXOX|OOXX|OXOO|OOOO|XX
YES++|OXXO|XXOX|OOXX|OXOO|OOOO|XX
4XO|OXXO|XXOX|OXXX|OX
NO
5XX|XXXX|XXXO|OXXO|OOOX|XO
YESXX|XXXX|XXXO|OXXO|++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
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;string a[1005];int main(){int n;int flag=0;scanf("%d",&n);getchar();for(int i=0;i<n;i++){cin>>a[i];}for(int i=0;i<n;i++){if(a[i][0]=='O' && a[i][1]=='O'){a[i][0]='+';a[i][1]='+';flag=1;break;}else if(a[i][3]=='O' && a[i][4]=='O'){a[i][3]='+';a[i][4]='+';flag=1;break;}}if(flag){printf("YES\n");for(int i=0;i<n;i++){cout<<a[i]<<endl;}}else{cout<<"NO"<<endl;}return 0;}
- CodeForces 711A A. Bus to Udayland
- codeforces 711A.Bus to Udayland 【水题】
- Codeforces 711A Bus to Udayland
- 【模拟】Codeforces 711A Bus to Udayland
- Codeforces 711A- Bus to Udayland
- Codeforces-711A-Bus to Udayland
- CodeForces 711A. Bus to Udayland【StringBuilder】
- CodeForces 711A Bus to Udayland
- codeforces 711 A. Bus to Udayland
- Codeforces 711A Bus to Udayland
- CodeForces 711A Bus to Udayland(水题)
- Codeforces Problem 711A Bus to Udayland(brute force+implementation)
- Codeforces-711A Bus to Udayland(找座位)
- codeforces——711A—— Bus to Udayland
- Codeforces Bus to Udayland
- A.Bus to Udayland
- A. Bus to Udayland
- A - Bus to Udayland
- ios,关于“按住说话”这个按钮的一个奇葩问题
- 多线程之间共享的资源有哪些
- gb2312转utf-8
- Unity3d游戏开发框架-标志量-数学管理类-时间管理-Log日志管理
- 码农如何在其他码农面前一本正经的装逼?懂点硬件知识
- Codeforces 711A- Bus to Udayland
- 106. Construct Binary Tree from Inorder and Postorder Traversal
- 传输控制协议--摘录
- Lua学习笔记(三)
- OpenGLES编程思想
- Go-指针、传值与传引用、垃圾回收
- MFC学习(3)对话框
- 【POJ 2454】Jersey Politics(RPの神Rand)
- 程序员兵器谱,带评论