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 1786. Sandro's Biography

WA#9
Posted by dastan 4 Jan 2012 22:56
I have true answers on all tests with this forum, but have WA#9! Help me!
This is my code:

#include <iostream>

using namespace std;

int main()
{
    char str[201];
    int c = 0;
    int cmax = 0;
    int index = 0;
    const char S[7] = {'S','a','n','d','r','o','\n'};
    gets(str);
    for(int i=0;i<strlen(str)-5;i++)
    {
        if(str[i]=='S') c+=2;
        if(str[i]=='s') c++;
        if(str[i+1]=='a') c+=2;
        if(str[i+1]=='A') c++;
        if(str[i+2]=='n') c+=2;
        if(str[i+2]=='N') c++;
        if(str[i+3]=='d') c+=2;
        if(str[i+3]=='D') c++;
        if(str[i+4]=='r') c+=2;
        if(str[i+4]=='R') c++;
        if(str[i+5]=='o') c+=2;
        if(str[i+5]=='O') c++;

        if(c>cmax)
        {
            cmax = c;
            index = i;
        }
    }
        c = 0;
        if((str[index]=='s')||((int(str[index])<=90)&&(str[index]!='S'))) c++;
        else if(str[index]!='S') c+=2;

        if((str[index+1]=='A')||((int(str[index+1])>90)&&(str[index+1]!='a'))) c++;
        else if(str[index+1]!='a') c+=2;

        if((str[index+2]=='N')||((int(str[index+2])>90)&&(str[index+2]!='n'))) c++;
        else if(str[index+2]!='n') c+=2;

        if((str[index+3]=='D')||((int(str[index+3])>90)&&(str[index+3]!='d'))) c++;
        else if(str[index+3]!='d') c+=2;

        if((str[index+4]=='R')||((int(str[index+4])>90)&&(str[index+4]!='r'))) c++;
        else if(str[index+4]!='r') c+=2;

        if((str[index+5]=='O')||((int(str[index+5])>90)&&(str[index+5]!='o'))) c++;
        else if(str[index+5]!='o') c+=2;
        cout<<c*5<<endl;
    return 0;
}
Re: WA#9
Posted by Morph 13 Mar 2012 00:08
Try the test:
sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnnnndroooooooooooooo
Your program's answer is 30.
The right answer is 15.
(
1.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnsnndroooooooooooooo
2.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnsandroooooooooooooo
3.sssssssssssssssssssssssssssssssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnSandroooooooooooooo
)
The wierd thing is that for "mmndro" the answer is right. :D
Re: WA#9
Posted by Morph 13 Mar 2012 00:16
I got the bug. In the first for, your c is always increasing, so your cmax will be wrong. Put "c=0" before to close the for.
It should work perfect now.
Re: WA#9
Posted by ViktYusk 24 Nov 2018 18:33
Thanks!