标签:
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include<vector> using namespace std ; typedef long long ll; const int N = 2000000 + 10; const int inf = 1e9 + 7; char a[N]; int len,H[N]; int check4() { if(len < 6) return 1; char b[10] = {‘j‘,‘i‘,‘g‘,‘g‘,‘l‘,‘e‘}; int cnt = 0; for(int i = 0; i < 6; i++) { if(a[i] != b[cnt]) return 1; cnt++; } return 0; } int check2() { if(len < 15) return 0; char b[30] = {"clap stomp clap"}; int cnt =0 ; for(int i = len - 15; i < len ;i ++) { if(a[i]!=b[cnt++]) return 0; } return 1; } int check5() { for(int i = 0; i < len - 2; i+=1) { if(a[i] == ‘d‘ && a[i+1] == ‘i‘ && a[i+2] == ‘p‘) return 1; } return 0; } int check3() { if(len < 5) return 1; for(int i = 0; i <= len - 5; i++) { if(a[i] == ‘t‘ && a[i+1] == ‘w‘ && a[i+2] == ‘i‘ && a[i + 3] == ‘r‘&&a[i+4]==‘l‘) { for(int i = 0; i < len - 2; i++) { if(a[i] == ‘h‘ && a[i+1] == ‘o‘ && a[i+2] == ‘p‘) return 1; } return 0; } } return 1; } void solve() { memset(H,0,sizeof(H)); vector<int> ans; len = strlen(a); if(!check2()) H[2] = 1; if(!check3()) H[3] = 1; if(!check4()) H[4] = 1; if( check5() ) { for(int i = 0; i < len - 2; i++) { if(a[i] == ‘d‘ && a[i+1] == ‘i‘ && a[i+2] == ‘p‘) { int f = 1; if(i - 7 >= 0) { int cnt2= 0; for(int j = i - 1; j >= 0 ; j--) { if(a[j] ==‘ ‘) cnt2++; if(cnt2 == 2) {cnt2 = j;break;} } if(cnt2 - 6 >= 0) { int flag = 0; char b[20] = {"jiggle"};int cnt = 0; for(int j = cnt2 - 6; j < cnt2; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } } if(i - 7 >= 0) { int flag = 0; char b[20] = {"jiggle "};int cnt = 0; for(int j = i - 7; j < i; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } if(i + 8 < len) { int flag = 0; char b[20] = {" twirl"};int cnt = 0; for(int j = i + 3; j <= i+8; j ++) { if(a[j]!= b[cnt++]) {flag =1;break;} } if(!flag) f = 0; } if(f) { a[i] = ‘D‘; a[i+1] = ‘I‘; a[i+2] = ‘P‘; H[1] = 1; } i += 2; } } } else H[5] = 1; for(int i = 1; i <= 5; i++) { if(H[i]) ans.push_back(i); } if(!ans.size())cout<<"form ok: "<<a<<endl; else if(ans.size()==1) printf("form error %d: %s\n",ans[0],a); else if(ans.size() == 2) printf("form errors %d and %d: %s\n",ans[0],ans[1],a); else if(ans.size() == 3) printf("form errors %d, %d and %d: %s\n",ans[0],ans[1],ans[2],a); else if(ans.size() == 4) printf("form errors %d, %d, %d and %d: %s\n",ans[0],ans[1],ans[2],ans[3],a); else if(ans.size() == 5) printf("form errors %d, %d, %d, %d and %d: %s\n",ans[0],ans[1],ans[2],ans[3],ans[4],a); } int main() { while(gets(a)!=NULL) { solve(); } return 0; }
UVALive 4222 /HDU 2961 Dance 大模拟
标签:
原文地址:http://www.cnblogs.com/zxhl/p/5151892.html