1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 5 using namespace std; 6 7 class WolfDelaymaster{ 8 public: 9 bool checkChar(string str, char c, int start ,int num){ 10 for(int i = start; i < start + num; ++ i ){ 11 if(str[i] != c) return false; 12 } 13 return true; 14 } 15 16 string check(string str){ 17 for(int i = 0; i < str.length();){ 18 int j = i; 19 while(str[j] == 'w' && ++ j); 20 int num = j - i; 21 if(num == 0 ) return "INVALID"; 22 if(checkChar(str,'0',j,num) && checkChar(str,'l',j+num,num) && checkChar(str,'f',j+2*num,num)) 23 { 24 i = j + 3*num; 25 } 26 else return "INVALID"; 27 } 28 return "VALID"; 29 } 30 31 };