RRSTONE - Editorial

Hello there,
I have referred to the AC solutions and editorial, but haven’t been able to figure out what wrong with mine.
Please help me to find my mistake.
Solution is in C#.

http://www.codechef.com/viewsolution/3894764

Thank you.

input

2 2
1 2

expected output is 0 1, because {1, 2} -> {1, 0} -> {0, 1}

your code returns 1 2 (http://ideone.com/WfXwGy )

@saurabh8c, I do not agree with your on your first paragraph, it’s not sadistic, in programming contests you always have to check what the worst case scenario will be like (even though it could be very hard on some problems). These are very common things in programming contests, there are also authors that specify if the answer can be held by a certain data type even though usually it’s not mandatory.

Thank you.
I have found my mistake in the code.
I want to ask few newbie doubts related to competitive programing.
I request you to please guide me for the same as to where can I ask them.

Do you mind if I drop you a PM.

Thank you.

May I know what was wrong with this code?
http://www.codechef.com/viewsolution/3894474

this is ur corrected code…http://www.codechef.com/viewsolution/3905612 the problem was that u were using 1 based indexing…so the the (10^5)th number was getting stored at a mem location that wasnt defined…and hence maybe was being replaced by garbage values so u had to declare an array of size (10^5)+1…hope this helps…:slight_smile:

Thank you. I got it now :slight_smile:

Can someone pls tell me whats wrong with this code? It says wrong answer.
http://www.codechef.com/viewsolution/3924704

I have used the same approach as described above. Can anyone tell me why it gives WA?
http://www.codechef.com/viewsolution/3873160

I think you need to include the case where k is 0

if we take array

4 6 8 1 7 10 so max is 10 so the array becomes 6 4 2 9 3 0. Now max is 9 so arrays becomes 3 5 7 0 6 9. It doesnt repeat after 2 cycles. Explain me please

observe this pattern:

1-> 4 6 8 1 7 10 ; max = 10

2-> 6 4 2 9 3 0 ; max = 9

3-> 3 5 7 0 6 9 ; max = 9

4-> 6 4 2 9 3 0 ; max = 9

5-> 3 5 7 0 6 9 ; max = 9

6-> 6 4 2 9 3 0 ; max = 9


so from step 2 each step repeats after 2 cycles

I belong to the category who specify the data type if it may not be clear to the user. That is why I mentioned that it is a subjective topic.

Can someone pls tell me whats wrong with this code? It saystime limit exceeded.

http://www.codechef.com/viewsolution/3892697

your algorithm complexity is O(N*K)

as

1 <= N <= 10^5

0 <= K <= 10^9

so in worst case N*K can be 10^14

since you are looping from 0 to 10^14(beyond 10^9) you are getting TLE.

I mean actual test cases may not contain upto 10^14 but if it contains beyond 10^9 you may get TLE

Thanks. Made the same mistake.

Hi.! I was wondering if anyone could help me with my code. Its working fine on my PC but gives WA whenever I try to submit it here on CC. The link to my solution is http://www.codechef.com/viewsolution/7170559

can someone explain the complexity of the editorial code?

Testcases for this question seems to be broken. I tried few times and unable to get the correct answer.
Then I copy pasted TESTER’s(link) solution(link) to check the same and still WA.
Please check the same.

How you guys come up with solution of this problem the way author has described? I mean I had no clue I could’ve has done this. (array repeating after two cycles)