A. Bus to Udayland
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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 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?
InputThe 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.
OutputIf 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.
Examplesinput6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XXoutputYES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XXinput4
XO|OX
XO|XX
OX|OX
XX|OXoutputNOinput5
XX|XX
XX|XX
XO|OX
XO|OO
OX|XOoutputYES
XX|XX
XX|XX
XO|OX
XO|++
OX|XONoteNote 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并将它们转换成+输出。
附AC代码:
#include<bits/stdc++.h>
using namespace std; int main(){
char s[][];
int n;
int ans=;
int flag=;
cin>>n;
while(n--){
cin>>s[ans];
if(s[ans][]=='O'&&s[ans][]=='O'&&!flag){ flag=;
s[ans][]='+';
s[ans][]='+'; }
else if(s[ans][]=='O'&&s[ans][]=='O'&&!flag){ flag=;
s[ans][]='+';
s[ans][]='+'; }
ans++;
}
if(flag){
cout<<"YES"<<endl;
for(int i=;i<ans;i++){
cout<<s[i]<<endl;
}
}
else
cout<<"No"<<endl;
return ;
}
A. Bus to Udayland的更多相关文章
- codeforces 711A A. Bus to Udayland(水题)
题目链接: A. Bus to Udayland 题意: 找一对空位坐下来,水; 思路: AC代码: #include <iostream> #include <cstdio> ...
- Codeforces Round #369 (Div. 2) A. Bus to Udayland 水题
A. Bus to Udayland 题目连接: http://www.codeforces.com/contest/711/problem/A Description ZS the Coder an ...
- Codeforces Round #369 (Div. 2) A. Bus to Udayland【字符串/二维字符数组求连起来的座位并改为其他字符】
A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #369 (Div. 2) A. Bus to Udayland (水题)
Bus to Udayland 题目链接: http://codeforces.com/contest/711/problem/A Description ZS the Coder and Chris ...
- CodeForces 711A Bus to Udayland (水题)
题意:给定一个n*4的矩阵,然后O表示空座位,X表示已经有人了,问你是不能找到一对相邻的座位,都是空的,并且前两个是一对,后两个是一对. 析:直接暴力找就行. 代码如下: #pragma commen ...
- 【模拟】Codeforces 711A Bus to Udayland
题目链接: http://codeforces.com/problemset/problem/711/A 题目大意: N个字符串,每个字符串5位,找到第一个出现两个OO的并改成++输出YES和改后字符 ...
- CodeForces 711A Bus to Udayland
简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...
- 洛谷 题解 CF711A 【Bus to Udayland】
先用一个字符数组存每行的座位情况(字符变量也可以) 接下来用另一个数组存最后的座位情况 好了,看代码 #include<iostream> using namespace std; boo ...
- Codeforces Round #369 (Div. 2) A B 暴力 模拟
A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- 【面试 hibernate】【第二篇】hibernate相关问题
1.hibernate工作原理[说一下你怎么理解的hibernate] hibernate是一个ORM对象关系映射的持久层框架,是对JDBC的轻量级封装. [可以不记,hibernate核心接口] 1 ...
- 使用JavaScript进行进制转换将字符串转换为十进制
JS 是一个很神奇的语言,内制的的很多函数可以帮我们进行数(进)制转换: JS中可以直接使用16进制: var a = 将任意进制字符串转换为十进制,如二进制,八进制,十六进制, 第二数数不写即为最常 ...
- Android——ListView优化
1.ListView基本概念 列表显示需要三个元素: ListView:用来展示列表的View. 适配器:用来把数据映射到ListView上 数据:具体的将被映射的字符串,图片或基本组件 适配器类型分 ...
- Android逆向利器和smali代码修改出错举例-入参类型
当smali修改代码出错举例1,log如下: 虚拟机层次: 1.本身做出了预测,寄存器v2是符合要求入参,暗示你这个也许是你想要的.VFY: register1 v2 type 17, wanted ...
- Linux环境下如何查找哪个线程使用CPU最长
top -H -p pid 查看端口是否被占用: netstat -apn|grep 80
- <十二>读<<大话设计模式>>之状态模式
对于状态模式,<<大话设计模式>>是以人从上班到下班到加班的状态来展开讲述的.状态模式事实上就是某一个对象在某个过程或者时间的一个状态记录,可是这个状态的顺序不能发生变化.在程 ...
- 设置GridCtrl中的Checkbox 为不可编辑
m_Grid.SetCellType(index, 1, CGridCtrl::CellType_Check); //设置第index行.第一列的单元格为类似CheckBox的模样 m_Gr ...
- delphi中的HOOK [转贴]
按事件分类,有如下的几种常用类型的钩子: 1)键盘钩子可以监视各种键盘消息. 2)鼠标钩子可以监视各种鼠标消息. 3)外壳钩子可以监视各种Shell事件消息. 4)日志钩子可以记录从系统消息队列中取出 ...
- 【读书笔记】iOS-GCD-用法
代码: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { dispatch_async(dispatch_get_gl ...
- POJ 2886 Who Gets the Most Candies?(树状数组+二分)
题目链接 注意题目中给的顺序是顺时针的,所以在数组中应该是倒着存的.左就是顺时针,右就是逆时针.各种调试之后,终于A了,很多种情况考虑情况. #include <cstring> #inc ...