ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2023. Donald is a postman

Here is my ac code and very simple to undestand on c++
Posted by nick nikuradze 8 May 2016 01:03
#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;
}