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 1404. Easy to Hack!

Poor test case
Posted by Haloom 2 Jul 2018 18:44
the original answer of fskdkskylp is ansthisone but my accepted code give this answer aêsthisone.


my accepted code


#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c[104];
    scanf("%s",c);
    int l=strlen(c);
    int a[l+5];
    int b[l+5];
    for(int i=0; i<l; i++)
    {
        a[i]=c[i]-'a';
    }
    b[0]=a[0];
    if(a[0]<5)
    {
        b[0]=b[0]+26;
    }
    for(int i=1; i<l; i++)
    {
        int j=1;
        while((b[i]=a[i]+j*26))
        {
            if(b[i]%26==a[i]&& b[i]>=b[i-1])
                break;
            j++;
        }
    }
    printf("%c",b[0]-5+'a');
    for(int i=1; i<l; i++)
    {
        int j=abs(b[i]-b[i-1]);
        printf("%c",j+'a');
    }
    printf("\n");
    return 0;
}