VJ_Game with string_stack

//
#include<bits/stdc++.h>
using namespace std;

int main()
{
    stack<char> sk;
    string s;
    int i,k1,k2;

    while( getline( cin,s ) )
    {
        while( !sk.empty() ) sk.pop();

        k1=0; k2=1;
        for( i=0;i<s.size();i++ )
        {
            if( !sk.empty() && sk.top()==s[i] )
            {
                sk.pop(); swap( k1,k2 );
            } 
            else sk.push( s[i] );
        }
        if( k1 )    cout<<"Yes"<<endl;
        else        cout<<"No"<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_63173957/article/details/124615310
vj