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 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.
Sample Input
6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
Sample Output
YES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
Hint
题意
给你一个4n的公交车座椅排布,然后问你有没有一个连着的,两个人可以坐的位置。
题解:
直接暴力check一下就好了`
代码
#include<bits/stdc++.h>
using namespace std;
vector<string>ans;
int main()
{
int n;
scanf("%d",&n);
int flag = 0;
for(int i=0;i<n;i++)
{
string s;
cin>>s;
if(flag==0)
{
if(s[0]=='O'&&s[1]=='O')
{
flag = 1;
s[0]='+',s[1]='+';
}
}
if(flag==0)
{
if(s[3]=='O'&&s[4]=='O')
{
flag = 1;
s[3]='+',s[4]='+';
}
}
ans.push_back(s);
}
if(flag==0)printf("NO\n");
else
{
printf("YES\n");
for(int i=0;i<n;i++)
cout<<ans[i]<<endl;
}
}
Codeforces Round #369 (Div. 2) A. Bus to Udayland 水题的更多相关文章
- 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 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 ...
随机推荐
- SQL Server 的字段不为NULL时唯一
CREATE UNIQUE NONCLUSTERED INDEX 索引名称ON 表名(字段) WHERE 字段 is not null SQL Server 2008+ 支持
- 略显犀利的 js 判断闰年
/** * 判断闰年函数 * @param {number} year 要判断的年份 * @return {bool} 返回布尔值 * * 其实只要满足下面几个条件即可. * 1.普通年能被4整除且不 ...
- ODPS_ele—UDF Python API
自定义函数(UDF) UDF全称User Defined Function,即用户自定义函数.ODPS提供了很多内建函数来满足用户的计算需求,同时用户还可以通过创建自定义函数来满足不同的计算需求.UD ...
- 用Java构建一个简单的WebSocket聊天项目之新增HTTP接口调度
采用框架 我们整个Demo基本不需要大家花费太多时间,就可以实现以下的功能. 用户token登录校验 自我聊天 点对点聊天 群聊 获取在线用户数与用户标签列表 发送系统通知 首先,我们需要介绍一下我们 ...
- HDU 1875 畅通工程再续 最小生成树问题
题目描述:输入一个T,表示有T组测试数据,然后每组测试数据有一个C,表示在一个湖里面有C座岛屿,现在要在岛屿之间修建桥,可以修建必须满足的条件是岛与岛之间的距离在10到1000的范围内,然后给出每座岛 ...
- 数据结构笔记之跳表(SkipList)
一.跳表简述 跳表可以看做是一个带有索引的链表,在介绍跳表之前先看一下一个普通的链表,假如当前维护了一个有序的链表: 现在要在这个链表中查找128,因为事先不知道链表中数值的分布情况,我们只能从前到后 ...
- vue实践中的狗血事件之:mock数据引发的血坑
在项目实践中,遇到了这么一档子事 开发环境下,很快乐,什么事儿都没有,于是想打包一下测一下自动登录的效果 好家伙,一开始登录没有效,改来改去,最后连路由都切换不了, 明明开发环境下好好的,为毛打包后就 ...
- artDialog学习之旅(二)之扩展方法详解
名称 描述 核心方法 art.dialog.top 获取artDialog可用最高层window对象.这与直接使用window.top不同,它能排除artDialog对象不存在已经或者顶层页面为框架集 ...
- spfa求图的最大流
题目链接: https://vjudge.net/contest/255738#problem/B AC代码: #include <iostream> #include<vector ...
- thinkphp5学习总结!
数据库操作之原生sql操作 <?php namespace app\index\controller; use think\Db; class Index { public function i ...