【模拟】Codeforces 711A Bus to Udayland

本文解析了 CodeForces 平台上的 711A 题目,该题要求从 N 个五位字符串中找出第一个含有连续两个 'OO' 的字符串,并将其替换为 '++'。通过简单的模拟算法,文章提供了 C++ 实现代码,展示了如何快速解决这一签到级别的编程挑战。

题目链接:

  http://codeforces.com/problemset/problem/711/A

题目大意:

  N个字符串,每个字符串5位,找到第一个出现两个OO的并改成++输出YES和改后字符串,没有输出NO.

题目思路:

  【模拟】

  签到题。看阅读理解能力和手速。

 

 1 //
 2 //by coolxxx
 3 //#include<bits/stdc++.h>
 4 #include<iostream>
 5 #include<algorithm>
 6 #include<string>
 7 #include<iomanip>
 8 #include<map>
 9 #include<stack>
10 #include<queue>
11 #include<set>
12 #include<bitset>
13 #include<memory.h>
14 #include<time.h>
15 #include<stdio.h>
16 #include<stdlib.h>
17 #include<string.h>
18 //#include<stdbool.h>
19 #include<math.h>
20 #define min(a,b) ((a)<(b)?(a):(b))
21 #define max(a,b) ((a)>(b)?(a):(b))
22 #define abs(a) ((a)>0?(a):(-(a)))
23 #define lowbit(a) (a&(-a))
24 #define sqr(a) ((a)*(a))
25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
26 #define mem(a,b) memset(a,b,sizeof(a))
27 #define eps (1e-8)
28 #define J 10
29 #define mod 1000000007
30 #define MAX 0x7f7f7f7f
31 #define PI 3.14159265358979323
32 #define N 1004
33 using namespace std;
34 typedef long long LL;
35 int cas,cass;
36 int n,m,lll,ans;
37 char s[N][10];
38 int main()
39 {
40     #ifndef ONLINE_JUDGE
41 //    freopen("1.txt","r",stdin);
42 //    freopen("2.txt","w",stdout);
43     #endif
44     int i,j,k;
45     
46 //    for(scanf("%d",&cass);cass;cass--)
47 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
48 //    while(~scanf("%s",s+1))
49     while(~scanf("%d",&n))
50     {
51         for(i=1;i<=n;i++)
52             scanf("%s",s[i]);
53         for(i=1;i<=n;i++)
54         {
55             if(s[i][0]==s[i][1] && s[i][0]=='O')
56             {
57                 s[i][0]=s[i][1]='+';
58                 break;
59             }
60             else if(s[i][3]==s[i][4] && s[i][3]=='O')
61             {
62                 s[i][3]=s[i][4]='+';
63                 break;
64             }
65         }
66         if(i<=n)
67         {
68             puts("YES");
69             for(i=1;i<=n;i++)
70                 puts(s[i]);
71         }
72         else puts("NO");
73     }
74     return 0;
75 }
76 /*
77 //
78 
79 //
80 */
View Code

 

转载于:https://www.cnblogs.com/Coolxxx/p/5821994.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值