https://www.jisuanke.com/contest/7332/386137
思路:仔细观察,发现我们要做的就是将a与b匹配(就像括号一样)并允许c移到任何地方
#include <bits/stdc++.h>
using namespace std;
stack<char> mystack;
bool fun(string s)
{
for(int i=0; i<s.size(); i++) {
if(s[i]=='a')
mystack.push('a');
else if(s[i]=='b') {
if(mystack.empty())
return false;
else
mystack.pop();
}
else if(s[i]!='c')
return false;
}
return mystack.empty();
}
int main()
{
int n;
scanf("%d", &n);
for(int k=1; k<=n; k++)
{
string s;
cin>>s;
while(!mystack.empty() )
mystack.pop();
if(fun(s))
printf("Pattern %d: More aliens!\n",k);
else
printf("Pattern %d: Still Looking.\n",k);
if(k!=n)
printf("\n");
}
return 0;
}