0
点赞
收藏
分享

微信扫一扫

堆栈操作合法性

堆栈操作合法性_ios

 

1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6 {
7 int n,c = 0,m;
8 cin>>n>>m;
9 string s;
10 while(n--)
11 {
12 cin>>s;
13 c = 0;
14 for(int i = 0; i < s.size(); i ++)
15 {
16 if(s[i] == 'S')
17 {
18 c ++;
19 if(c > m)
20 break;
21 }
22 else
23 {
24 c --;
25 if(c < 0)
26 break;
27 }
28 }
29 if(c == 0)
30 cout<<"YES"<<endl;
31 else
32 cout<<"NO"<<endl;
33 }
34 }

 


举报

相关推荐

0 条评论