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. 4-EasyNetQ之Logging(黄亮翻译)

    EasyNetQ提供了一个Logger接口 IEasyNetQLogger: public interface IEasyNetQLogger { void DebugWrite(string for ...

  2. Mysql学习—查看表结构、修改和删除数据表

    原文出自:http://blog.csdn.net/junjieguo/article/details/7668775 查看表结构 查看表结构可以用语句DESCRIBE或SHOW CREATE TAB ...

  3. [xdoj1007]易碎的鸟蛋(dp)

    解题思路:f[n,m]表示n层楼.m个鸡蛋时所需要的最小次数,则 转移方程为:f[n,m] = min{ 1+max(f[i-1,m-1], f[n-i,m]) | i=1..n }初始条件:f[i, ...

  4. ==, equals, hashcode的理解

    一.java对象的比较 等号(==): 对比对象实例的内存地址(也即对象实例的ID),来判断是否是同一对象实例:又可以说是判断对象实例是否物理相等: equals(): 对比两个对象实例是否相等. 当 ...

  5. cmake中设置ELF文件加载动态库的位置

    1. 三个文件 1. world.c #include<stdio.h> void world(void) { printf("world.\n"); } 2. hel ...

  6. 前端学习笔记2017.6.12 DIV布局网页

    DIV的功能就是把网页划分成逻辑块的. 看下豆瓣东西页面的布局,我们来分析下. 按照先从上到下的原则,把这个页面分成几个块: 首先是最顶端的这个条,这是一个DIV,我们给它起个名字,叫banner 然 ...

  7. spark sql使用sequoiadb作为数据源

    目前没有实现,理一下思路,有3中途径: 1:spark core可以使用sequoiadb最为数据源,那么是否spark sql可以直接操作sequoiadb. 2: spark sql支持Hive, ...

  8. Day Day Up—— ——fseek()函数的用法

    在牛客网遇到的一个程序题中用到了函数fseek()故查阅了一下该函数的功能及用法,整理如下: fseek函数功能是把文件指针指向文件的开头,需要包含头文件stdio.h 功 能: 重定位流上的文件指针 ...

  9. 数据结构 Job

    问题描述 有 n 项工作在等待队列中等待处理,编号为 1-n. 每个工作有个优先级 p.处理机同一时间只能处理一项工作.处理机决定接下来处理哪一项工作的方式为:从队首取出一项工作 x,若等待队列中没有 ...

  10. 《Effective Java》第4章 类和接口

    第13条:使类和成员的可访问性最小化 第一规则很简单:尽可能地使每个类或者成员不被外界访问.换句话说.应该使用与你正在编写的软件的对应功能相一致的.尽可能最小的访问级别. 对于顶层的(非嵌套的)类和接 ...