|
|
back to boardHere is my ac code and very simple to undestand on c++ #include <iostream> using namespace std; int main() { int n; cin>>n; string s; int a=1; int counter=0; for(int i=0; i<n; i++) { cin>>s; if((s[0]=='A' || s[0]=='P' || s[0]=='R' || s[0]=='O' ) && a==2) { a=1; counter++;} else if((s[0]=='A' || s[0]=='P' || s[0]=='R' || s[0]=='O' ) && a==3) { a=1; counter+=2;} else if((s[0]=='B' || s[0]=='M' || s[0]=='S') && a==1){ a=2; counter++;} else if((s[0]=='B' || s[0]=='M' || s[0]=='S') && a==3){ a=2; counter++;} else if((s[0]=='D' || s[0]=='G' || s[0]=='J' || s[0]=='K' || s[0]=='T' || s[0]=='W' ) && a==1) { a=3; counter+=2;} else if((s[0]=='D' || s[0]=='G' || s[0]=='J' || s[0]=='K' || s[0]=='T' || s[0]=='W' ) && a==2) { a=3; counter++;}
} cout<<counter; system("pause"); return 0; } |
|
|