​传送门​​​ 题意:能否找出连续相同的字符删除,如果可以,那么删除,并且再判断。
最后找不出的输掉比赛。
思路:判断对数的奇偶即可。
主要是删除之后再判断比较难想。
用栈处理比较容易了,且易理解。

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string.h>
#include<stack>
using namespace std;
int main() {
string a;
stack<char>q;
cin >> a;
int cnt=0;
for(int i = 0; i < a.length(); i++) {
if(!q.empty()&&q.top() == a[i]) {
cnt++;
q.pop();
} else {
q.push(a[i]);
}

}
if(cnt%2==0)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
return 0;
}