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 ...
随机推荐
- Go -- go语言指针
package main import "fmt" type Test struct { Name string } func change2(t *Test) { t.Name ...
- 【转载】容器技术 & Docker & 与虚拟化的比较
看到10月份天天写博客,只有一天没写,非常棒! 11月份也基本每天都写,现在看到有三天没加新博客,应该是之前挖的坑太多了,需要填坑,呵呵. 那这篇文章是不是为了占坑呢?哈哈.我不说话. 容器技术,这篇 ...
- Tips/Tricks in Deep Neural Networks
转自: http://lamda.nju.edu.cn/weixs/project/CNNTricks/CNNTricks.html
- xgboost原理及并行实现
XGBoost训练: It is not easy to train all the trees at once. Instead, we use an additive strategy: fix ...
- 数据库官方在线文档列表(mysql, postgreSQL)
1. mysql http://dev.mysql.com/doc/ 2. postgreSQL https://www.postgresql.org/docs/
- weexapp 开发流程(三)其他页面创建
1.首页 (1)轮播图 步骤一:创建 轮播图 组件(Slider.vue) src / assets / components / Slider.vue <!-- 轮播图 组件 --> & ...
- 一览新的 Android Gradle 构建工具:新的 DSL 结构 和 Gradle 2.5
译者地址:[翻]一览新的 Android Gradle 构建工具:新的 DSL 结构 和 Gradle 2.5 原文:First Look at New Android Gradle Build To ...
- Jenkins系列之-—07 集成JIRA
一.Jenkins Jira插件安装&配置 1. 安装插件,主要安装如下插件: Jira Issue Updater 该插件用于更新JIRA ISSUES 的工作流状态或增加备注 JIRA p ...
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)
sql server 关于表中只增标识问题 由于我们系统时间用的过长,数据量大,设计是采用自增ID 我们插入数据的时候把ID也写进去,我们可以采用 关闭和开启自增标识 没有关闭的时候 ,提示一下错 ...
- oracle SQL语句(转)
Oracle数据库语句大全 ORACLE支持五种类型的完整性约束 NOT NULL (非空)--防止NULL值进入指定的列,在单列基础上定义,默认情况下,ORACLE允许在任何列中有NULL值. CH ...