cf D. Alternating Current

时间:2022-05-30 10:09:39

http://codeforces.com/contest/344/problem/D

 #include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
using namespace std; char str[];
int main()
{
stack<char>q;
scanf("%s",str);
int k=strlen(str);
for(int i=; i<k; i++)
{
if(q.empty())
{
q.push(str[i]);
}
else if(str[i]==q.top())
{
q.pop();
}
else if(str[i]!=q.top())
{
q.push(str[i]);
}
}
if(!q.empty()) printf("No\n");
else printf("Yes\n");
return ;
}