PETERSEN - Editorial

Hi during the testing I created list of basic test cases:

Solution is @Shashwat.delhi’s I just modified it such, that when line starts with ‘#’ I print this line and continue with next - it’s easier to navigate in test cases then…

Hi, I considered as two graphs one as outer and other as inner. There can by only one path after that we can determine after examining 1st three vertices in the string.Can someone please help me to find out where i am missing?

here is my solution link: CodeChef: Practical coding for everyone

Please tell where does my code fails…

I have tried all corner cases.

Hii everybody… m getting RTE(sigabrt) plz give me a test case 4 dis.

link:fTs2JF - Online C++ Compiler & Debugging Tool - Ideone.com

Hi, I still can’t access the tester and setter’s solutions. Please help. On clicking the links, the following message is shown:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

Access denied to setter and tester solution

The solutions can’t be accessed.

They will be uploaded soon.

Well secret doesn’t work (read the contest rules again) and if he made his solution private, he couldn’t link it here…

LOGIC

4 Likes

The ideone snippet was created after the contest ended, so it shouldn’t be a problem.

3 Likes

pastebin.com, really? Why?

I did not understand your approach with modular arithmetic thing, for example difference AA is 5, difference AD is 3…

Your submitted code returns for

2
AABD
AABE

only

-1

I missed that “lexicographically least” part completely, but fortunately no problem…

I replaced the picture with the one from problem statement, it seems to me, that origin URL is not reachable… If it was different picture, please fix the link.

The NZEC might be due to stack overflow. Try a bottom-up approach without any recursion.

@nisargshah95:
I tried AAAA…(5000 times) to check for stack overflow on ideone, runs perfectly fine, guess that’s not it.

@kostya_by: any thoughts? Could you provide test cases used now that the contest is over?

I have checked for all corner cases…My solution passed all test cases generated by betlista… Could somebody help me where i am missing? Or provide the test cases used for evaluation?

try:

1
CEA

@vijju123 @admin I can’t access setter’s and tester’s solution. Please fix the links.

This problem can also be solved with elementary knowledge of array, 1d, 2d

⮊ make two arrays p, q  

    pᵢ is the min-node-value of i eg pₐ = 0  

    qᵢ is the max-node-value of i eg qₐ = 5

⮊  make an array from[5][5] where fromᵢⱼ = node-value of the i  in edge i➜ j

    e.g. for A⟷B fromₐᵦ = 0   

⮊  similarlry, make an array to[5][5] where toᵢⱼ = node-value of the j  in edge i ➜ j

    e.g. for A⟷B toₐᵦ = 1   

☪ here i, j ∈ {A,B,C,D,E}

    fromᵢⱼ , toᵢⱼ are always unique, except when i≣j (small manipulatⁿ to fix it, do later)

☪ assuming 0-based indexing , i.e., 1st ele in the string is at s₀   

The test case can be categorize in two types:-

1️⃣ when all the letters in strings are same i.e., AAA, BBBB, C

    answer :  pᵢqᵢpᵢqᵢpᵢ…………    (think why ? ∵ lexicographic string, see defⁿ of p, q above)

2️⃣ this case has nothing to do with lexicoraphic propt. 

    ⮚ let say string s = 'AAAABBEECD', n = s.length = 10

    ⮚ assume answer be array ans[10]

    ⮚ we'll work on prefix 'AAAA' 

        ⮚ since  fromₐᵦ = 0, toₐᵦ = 1 

        ⮚ ans₃ =  fromₐᵦ = 0 

        ⮚ ans₄ =  toₐᵦ = 1

        ⮚ work reversely for getting ans₂,ans₁,ans₀ 

            ⮚this is easy task similiar to 1️⃣ , since ans₃ = 0 ∴ we have ans₂=5, ans₁=0, ans₀=5   ☪ in the problem we don't have self loops i.e., 0 ➜ 0,5 ➜ 5, not possible but  0 ➜ 5, 5 ➜ 0 is possibile

    ☪ prefix in this context  here means the consecutive same  letters at the beginnning of the string which in this particular case if 'AAAA'

    

    ⮚ now we are down with exhaustive part of the prefix 

        ⮚ now take help of array from[][], to[][] to directly find ans₅ in similiar ways as we found ans₄ 

            ⮚ but this time do not go backward to find ans₄, ans₃,………… since we are done with them 

        ⮚ proceed further for ans₆,... so on  [similiar to ans₅ ]

#use type casting to convert ascii value 48-52 to A-E

:star: you can see that that you can proceed in same way on any other test case , this is the more general test case , which suffice’s to explain all the possisbility