Two people are playing a game with a string ss, consisting of lowercase latin letters.

On a player's turn, he should choose two consecutive equal letters in the string and delete them.

For example, if the string is equal to "xaax" than there is only one possible turn: delete "aa", so the string will become "xx". A player not able to make a turn loses.

Your task is to determine which player will win if both play optimally.

Input

The only line contains the string ss, consisting of lowercase latin letters (1≤|s|≤100000), where |s||s| means the length of a string ss.

Output

If the first player wins, print "Yes". If the second player wins, print "No".

Examples

input

Copy

abacaba

output

Copy

No

input

Copy

iiq

output

Copy

Yes

input

Copy

abba

output

Copy

No

Note

In the first example the first player is unable to make a turn, so he loses.

In the second example first player turns the string into "q", then second player is unable to move, so he loses.

思路:我们可以用栈来很好的表示这个过程,如果要入栈的字符和栈顶不一样,我们则将该元素压入栈中,如果要压入的元素和栈顶元素相同,我们则让栈顶元素出栈,但这个过程一定要满足栈不为空

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack> using namespace std;
char a[1000005];
stack<char> s;
int main()
{ scanf("%s",a);
int len=strlen(a);
s.push(a[0]);
int sum=0;
for(int t=1;t<len;t++)
{
if(!s.empty()&&a[t]==s.top())
{
s.pop();
sum++;
continue;
}
else
{
s.push(a[t]);
}
}
if(sum%2==0)
{
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
} return 0;
}

Codeforces-B-Game with string(模拟栈)的更多相关文章

  1. java 16 - 5 LinkedList模拟栈数据结构的集合

    请用LinkedList模拟栈数据结构的集合,并测试 题目的意思是: 你自己的定义一个集合类,在这个集合类内部可以使用LinkedList模拟. package cn_LinkedList; impo ...

  2. 第一回写的用arraylist模拟栈操作

    package hashMap; import java.util.ArrayList; import d.Student; /** * 用ArrayList模拟栈操作 * @author zhuji ...

  3. HDOJ/HDU 1022 Train Problem I(模拟栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  4. Hdu 3887树状数组+模拟栈

    题目链接 Counting Offspring Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java ...

  5. Java连载69-接受输入、用数组模拟栈

    一.编写一个酒店管理系统 1.直接上代码 package com.bjpowernode.java_learning; ​ public class D69_1_ { //编写一个程序模拟酒店的管理系 ...

  6. java模拟栈的操作

    栈是一种有序列表,可以使用数组的结构来储存栈的数据内容 思路 1. 创建一个栈类StackArray 2. 定义一个top来模拟栈顶,初始化为-1 3. 入栈: 当有数据加入到栈的时候 top++ s ...

  7. Stack (30)(模拟栈,输出中间数用set)

    Stack is one of the most fundamental data structures, which is based on the principle of Last In Fir ...

  8. 牛客编程巅峰赛S1第11场 - 黄金&钻石 A.牛牛的01游戏 (模拟栈)

    题意:有一个\(01\)串,两个相邻的\(0\)可以变成一个\(1\),两个相邻的\(1\)可以直接消除,问操作后的字符串. 题解:数组模拟栈直接撸,上代码吧. 代码: class Solution ...

  9. ACM/ICPC 之 用双向链表 or 模拟栈 解“栈混洗”问题-火车调度(TSH OJ - Train)

    本篇用双向链表和模拟栈混洗过程两种解答方式具体解答“栈混洗”的应用问题 有关栈混洗的定义和解释在此篇:手记-栈与队列相关 列车调度(Train) 描述 某列车调度站的铁道联接结构如Figure 1所示 ...

随机推荐

  1. 202. Happy Number 平方循环数

    [抄题]: Write an algorithm to determine if a number is "happy". A happy number is a number d ...

  2. 【摘自张宴的"实战:Nginx"】nginx模块开发

    Nginx的模块不能够像Apache那样动态的加载,所以模块都要预先编译进Nginx的二进制可执行文件中. Nginx的模块有三种角色: 1. Handler(处理模块)     用于处理Http请求 ...

  3. 项目一:在线下单(补充) activeMQ使用(重点) 重构客户注册功能,发短信功能分离

    1 课程计划 1.在线下单(补充) 2.activeMQ使用(重点) n 简介和安装 n activeMQ入门案例 n spring整合activeMQ应用 3.重构客户注册功能,发短信功能分离 n  ...

  4. Blender 工具使用——模式切换

    Blender 工具使用--模式切换 制作骨架时 在物件模式(Object Mode)下使用鼠标右键选中一个骨架,按Tab键,可以切换为编辑模式(Edit Mode),按Ctrl + Tab可以进入骨 ...

  5. 数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image 标签: 图像处理MATLAB 2017-

    实验要求: Reducing the Number of Gray Levels in an Image Objective To understand how the number of gray ...

  6. Luogu 2254 [NOI2005]瑰丽华尔兹

    简单dp,设$f_{i,j,k}$表示第i个时间段,钢琴处在(j,k)位置移动距离的最大值,那么有转移 $f_{i, j, k} = max(f_{i - 1, j, k}) ,  f_{i, j, ...

  7. redis过期时间设置

    方法一: $redis->setex(,'huahua'); 方法二: $redis->set('name','huahua'); $redis->expire('name',3);

  8. MediaRecorder录像那些事

    最近在做一个项目需要运用到MediaRecorder的API,之前都没接触过这部分,开始着手弄的时候各种各样的问题,真是让人崩溃呀! 最后通过网上的资料和大神的指点,当然也有自己几天坚持不懈的努力,终 ...

  9. JMeter上传文件 点选form-data依旧失败的解决方法

    转子:https://blog.csdn.net/xingyunpi/article/details/77930476 这几天一直在调用JMeter上传文件的一个接口,一直出错,在网上找到一些文章说的 ...

  10. PLSQL连接Oracle11g 64位

    目前plsql只有32位的,而Oracle11则是64位的,想要连接需要下载这个: 打开plsql,在Tools-->Prefences里面设置,如下图: 设置Oracle的主目录:下载文件解压 ...