~cpp #include<iostream.h> #include<string.h> bool isSlurpy(char* string,int* nowPointer,int arraySize); bool isSlimpy(char* string,int* nowPointer,int arraySize); bool isSlumpy(char* string,int* nowPointer,int arraySize); bool isFollowF(char* string,int* nowPointer,int arraySize); bool isNextCharacter(char* string,int* nowPointer,int arraySize,char checker); void main() { int testCount=0; cin>>testCount; bool* result; result = new bool[testCount]; int arraySize; char string[60]; int nowPointer; for(int i=0;i<testCount;i++) { cin>>string; arraySize=strlen(string); nowPointer=-1; result[i]=isSlurpy(string,&nowPointer,arraySize); } cout<<"\nSLURPYS OUTPUT\n"; for(int j=0;j<testCount;j++) { if(result[j]) cout<<"YES"; else cout<<"NO"; cout<<endl; } cout<<"END OF OUTPUT\n"; } bool isSlurpy(char* string,int* nowPointer,int arraySize) { if(isSlimpy(string,nowPointer,arraySize)) if(isSlumpy(string,nowPointer,arraySize)) { if((*nowPointer)+1==arraySize) return true; } return false; } bool isSlimpy(char* string,int* nowPointer,int arraySize) { if(isNextCharacter(string,nowPointer,arraySize,'A')) { if(isNextCharacter(string,nowPointer,arraySize,'H')) return true; else if(isNextCharacter(string,nowPointer,arraySize,'B') && isSlimpy(string,nowPointer,arraySize) && isNextCharacter(string,nowPointer,arraySize,'C')) return true; else if(isSlumpy(string,nowPointer,arraySize) && isNextCharacter(string,nowPointer,arraySize,'C')) return true; } return false; } bool isSlumpy(char* string,int* nowPointer,int arraySize) { if(isNextCharacter(string,nowPointer,arraySize,'D') ||isNextCharacter(string,nowPointer,arraySize,'E')) { if(isFollowF(string,nowPointer,arraySize)) { if(isNextCharacter(string,nowPointer,arraySize,'G')) return true; if(isSlumpy(string,nowPointer,arraySize)) return true; } } return false; } bool isFollowF(char* string,int* nowPointer,int arraySize) { if((*nowPointer)+1>=arraySize) return false; int count=0; while(string[(*nowPointer)+1]=='F') { (*nowPointer)++; count++; } if(count>0) return true; return false; } bool isNextCharacter(char* string,int* nowPointer,int arraySize,char checker) { if((*nowPointer)+1>=arraySize) return false; if(string[(*nowPointer)+1]==checker) { (*nowPointer)++; return true; } return false; }