Round#534 div.2-B Game with string

本文分享了在CodeForces平台解决B题的经验,通过分析字符串并消除重复字符对,最终判断结果是否为奇数。代码使用C++实现,涉及字符串操作、循环和条件判断。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

唔,第一次参加,掉了好多分。

http://codeforces.com/contest/1104/problem/B

不用考虑太多,string真的好厉害。

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<math.h>
 4 #include<iostream>
 5 #include<stdlib.h>
 6 #include<algorithm>
 7 #include<queue>
 8 #include<vector>
 9 #include<string>
10 #include<set>
11 #include<cctype>
12 #include<sstream>
13 #define mem(a) memset(a,0,sizeof(a))
14 #define LL long long
15 using namespace std;
16 const int N=1e2+5;
17 int a[N],n;
18 string s;
19 int main()
20 {
21   getline(cin,s);
22   int sum=0;
23   for(size_t i=0;i<s.size();i++)
24   {
25       while(s[i]==s[i+1]&&s.size())
26             {
27                 s.erase(i,2);
28                 i--;
29                 sum++;
30             }
31   }
32   cout<<(sum%2?"Yes":"No");
33     return 0;
34 }
View Code

 

转载于:https://www.cnblogs.com/XXrll/p/10307272.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值