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

WA8 c++. Help please
Posted by BUTKO_VNU 17 Nov 2015 11:26
#include <iostream>

using namespace std;

int main()
{
    char first[4] = { 'A', 'P', 'O', 'R' };
    char second[3] = { 'B', 'M', 'S'};
    int mail = 0;
    bool  AF=false;//already find
    char *input=new char[200];
    int steps=0,duck=1;
    cin >> mail;
    for (int i = 0; i < mail; i++)
    {
        cin >> input;
        for (int j = 0; j < 4;j++)
        {
            if (input[0] == first[j]&&!AF)
            {
                AF = true;
                if (duck == 1)break;
                if (duck == 2)steps++;
                if (duck == 3)steps += 2;
                duck = 1;
                break;
            }
        }
        if (!AF){
            for (int j = 0; j < 3; j++)
            {
                if (input[0] == second[j] && !AF)
                {
                    AF = true;
                    if (duck == 2)break;
                    else steps++;
                    duck = 2;
                    break;
                }
            }
        }
        if (!AF)
        {
            AF = true;
            if (duck == 3)break;
            if (duck == 2)steps++;
            if (duck == 1)steps += 2;
            duck = 3;
        }
            AF = false;

    }
    cout << steps;
    return 0;
}

Edited by author 17.11.2015 11:26
I found a solution to my problem was laziness. When I described the search for the third block - the answer was accepted as correct. Apparently in the verification test on the 8th provide those names are not on the shelves.

Edited by author 17.11.2015 11:35