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 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?
</big>
##Input
<big>
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.
</big>
##Output
<big>
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.
</big>
##Examples
<big>
input
6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
output
YES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
input
4
XO|OX
XO|XX
OX|OX
XX|OX
output
NO
input
5
XX|XX
XX|XX
XO|OX
XO|OO
OX|XO
output
YES
XX|XX
XX|XX
XO|OX
XO|++
OX|XO
</big>
##Note
<big>
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
</big>
<br/>
##题意:
<big>
找有没有相邻座位.
</big>
<br/>
##题解:
<big>
暴力判断一下即可.
</big>
<br/>
##代码:
``` cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <list>
#define LL long long
#define eps 1e-8
#define maxn 101000
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;
int n;
char str[1010][15];
int main(int argc, char const *argv[])
{
// IN;
while(scanf("%d" ,&n) != EOF)
{
for(int i=1; i<=n; i++) {
scanf("%s", str[i]);
}
bool flag = 0;
for(int i=1; i<=n; i++) {
if(str[i][0] == 'O' && str[i][1] == 'O') {
flag = 1;
str[i][0] = '+'; str[i][1] = '+';
break;
}
if(str[i][3] == 'O' && str[i][4] == 'O') {
flag = 1;
str[i][3] = '+'; str[i][4] = '+';
break;
}
}
if(!flag) printf("NO\n");
else {
printf("YES\n");
for(int i=1; i<=n; i++) {
printf("%s\n", str[i]);
}
}
}
return 0;
}
Codeforces Round #369 (Div. 2) A. Bus to Udayland (水题)的更多相关文章
- 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 #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- Java实验报告(一)
1.水仙花数 public class test1{ public static void main(String[] args){ for(int num=100;num<1000;num++ ...
- 2019 计蒜之道 初赛 第一场 商汤的AI伴游小精灵
https://nanti.jisuanke.com/t/39260 根据题意我们可以知道 这是一个树 我们只需要找到出度最大的两个点就好了 如果包含根节点的话要-- 两个点相邻的话也要-- 数据很 ...
- SSM框架之AOP、动态代理、事务处理相关随笔
AOP: 原理:底层利用动态代理(两种动态代理技术都使用了) 两种实现方案: 第一种:JDK动态代理技术 实现的InvocationHandler接口,要想实现某个类的动态代理对象,必须有接口有实现类 ...
- 【IO流】FileInputStream FileOutputStream BufferInputStream BufferOutputStream
FileInputStream IO流用来处理设备之间的数据传输. Java对数据的操作是通过流的方式. Java用于操作流的类都在IO包中. 流按流向分为两种:输入流,输出流. 流按操作类型分为两种 ...
- hihocoder 1636 : Pangu and Stones(区间dp)
Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first livi ...
- Qt项目界面文件(.ui)及其作用(超详细)
http://c.biancheng.net/view/1820.html Qt 项目中,后缀为“.ui”的文件是可视化设计的窗体的定义文件,如 widget.ui.双击项目文件目录树中的文件 wid ...
- MyBatis中批量insert
在orcale和mybatis执行批量插入是不一样的. orcale如下:(这里要注意的是:useGeneratedKeys="false" ) 方式1:oracle批量插入使用 ...
- Python format格式化时使用‘’{‘’或者‘’}‘’
用format格式化时,如果其中要用到‘’{‘’或者‘’}‘’,需要进行转义,否则报错 {{ ,}}使用同样的符号实现转义,而不是‘/’
- [效率神技]Intellij 的快捷键和效率技巧|系列一|常用快捷键
Intellij 是个功能强大的IDE,这里只讲window下社区版的Intellij. 1. 常用快捷: Alt+回车 导入包,自动修正Ctrl+N 查找类Ctrl+Shift+N 查找文件Ct ...
- 刷PTA这一周的感悟
在慕课上报名了浙江大学的<数据结构>这门课,主讲人陈越老师,何钦铭老师,两位老师讲的很好,课后有配套的PTA可以用来做题,练习. 最近在PTA上刷题,发现自己代码实现能力是真的差劲,一开始 ...