文章

11

粉丝

318

获赞

6

访问

100.9k

头像
用栈模拟即可
P1684 中南大学2019年机试题
发布于2020年4月16日 09:15
阅读数 9.5k

#include <bits/stdc++.h>
using namespace std;
char s[30];
stack<char> q;
int main()
{
    while(scanf("%s",s)!=EOF)
    {
        while(q.size()) q.pop();
        int cnt=0;
        for(char i='a';i<='z';i++)
        {
            q.push(i);
            while(!q.empty()&&q.top()==s[cnt])
            {
                cnt++;
                q.pop();
            }
        }
        if(q.empty()) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发