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!

WA1
Posted by smmac72 [ 🐊] 25 Aug 2018 05:59
I tried to do it with char input, the same happens.
tested everything I could find, but passed all the tests
don't know what to do


#include <iostream>
#include <string>
using namespace std;


int main()
{
    string alf = "abcdefghijklmnopqrstuvwxyz";
    char alp[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
    string inp;
    cin >> inp;
    short *arr = new short[inp.length()];
    short *out = new short[inp.length()];
    short prev = 0;
    for (short i = 0; i < inp.length(); i++)
    {
        short num = alf.find(inp[i]) + 1;
        if (num <= 5)
            num += 26;
        while (arr[i - 1] > num)
            num += 26;
        arr[i] = --num;
    }
    out[0] = arr[0] - 5;
    for (short i = 1; i < inp.length(); i++)
        out[i] = arr[i] - arr[i - 1];
    for (int i = 0; i < inp.length(); i++)
        cout << alf[out[i]];

    delete[] arr;
    delete[] out;
    return 0;
}