Need help with one test file for problem INTXOR

For n = 6 , I used questions using this pattern. Let the six indices be a , b, c, d , e ,f;

  1. a b c
  2. a b d
  3. c d e
  4. c d f
  5. e f a
  6. e f b

And for remaining I used similar pattern for finding indexes in multiple of 4. For instance let indices be i,j,k,l.

  1. i j k
  2. i j l
  3. k l i
  4. k l j

You can see my solution that the given pattern works. Solution link is
Solution Link

This answer was just to suggest a new kind of pattern. And sorry I was not able to solve your query.

Did you try to flush the output after printing the answer? Not sure if it helps, just a thought.

It is definitely TLE while it is shown as WA(-1.00).

Try to run your solution in Python 2.7. Same source code should work but you will get WA (-1.00) for all test cases.

You can also make small modification for your code to make it a bit faster by pre-allocating the memory for the res list. The modification (only relevant part is shown) looks like this:

for _ in xrange(t):
    n = int(raw_input())
    d = n/4
    i = 1
    res = [2]*(n+1)
    if n%4 == 0:
        for _ in xrange(d):
            r4 = solveFor4(i, i+1, i+2, i+3)
            for j in range(4):
                res[i+j] = r4[j]
            i += 4
    elif n%4 == 2:
        for _ in xrange(d-2):
            r4 = solveFor4(i, i+1, i+2, i+3)
            for j in range(4):
                res[i+j] = r4[j]
            i += 4
        r5 = solveFor5(i, i+1, i+2, i+3, i+4)
        for j in range(5):
            res[i+j] = r5[j]
        i += 5
        r5 = solveFor5(i, i+1, i+2, i+3, i+4)
        for j in range(5):
            res[i+j] = r5[j]
    else:
        for _ in xrange(d-1):
            r4 = solveFor4(i, i+1, i+2, i+3)
            for j in range(4):
                res[i+j] = r4[j]
            i += 4
        if n%4 == 1:
            r5 = solveFor5(i, i+1, i+2, i+3, i+4)
            for j in range(5):
                res[i+j] = r5[j]
        else:
            r7 = solveFor7(i, i+1, i+2, i+3, i+4, i+5, i+6)
            for j in range(7):
                res[i+j] = r7[j]
    print " ".join([str(x) for x in res])
    output = int(raw_input())
    if output != 1:
        break

With this modification your code runs faster, and you will get AC on the problem test case.

1 Like

It was because of TLE.

I changed res = res +…
to res+=

and it was accepted

check the code here https://ideone.com/OaN571

I did it in the same manner, although this method is a bit naive but it got me an AC, here is my implementation
https://www.codechef.com/viewsolution/21976641

@vijju123: What should be the next steps? Do you think it is okay to punish the participants for issues with the judge? We spend a lot of time trying to debug our code since we trust the verdict given by the judge.

Yes, its perfectly fine to punish participants here. You ought to read the interactive problem guides before first, which clearly state that if your code does not terminate after the judge gives a WA verdict, you can crash judge and get any verdict (except AC) which can be TLE, WA or some weird RE:XXXXXX.

I think it's something with how judge interact with output produced in python3(Not Sure).

Unless there are 0 accepted solutions n python 3, this claim cannot be explored.

 In python3 here 2. In C++14 here

Its much more likely you unconsciously did a very minor change while translating to C++ code which fixed the error? Also, your way to terminate the program in python seems unnatural.

Clarifying my statement-

In case the participants code does something unexpected causing your code to crash, a -1 verdict is given. And since the program crashed, you cannot count on it to give correct verdict.

Its not possible to account for ALL possible cases. For all we know, the participant may output a string instead of number, like “Enter a number” or output some weird large number as string output any random damn thing he could xD. Hence, its not possible to make judge 100% crash proof unless all the infinite possible behaviors of thousands of coders are accounted for. But please know, the judge will work and give correct verdict if you do everything as expected, i.e. adhere to I/O format and use correct algorithm. I feel this answers your doubt?

1 Like

I just found this discussion: Interactive Problems and the way to deal with them! - #4 by ad783 - tutorial - CodeChef Discuss
If it really was a TLE being shown as WA, then I’m probably done with codechef in general and long contests in particular.
Someone please tell me that it really was a wrong answer, not a TLE otherwise I’ll probably go mad after spending 2 days on debugging my logic. I got so frustrated that I didn’t attempt any question after that, leading to a ratings decline with demotion to div 2.

Thanks for your reply. My code can be found here: G46A36 - Online IDE & Debugging Tool - Ideone.com
Do you know why regular cyclic flow doesn’t work for group of 6 leading to redundant equations?
Also, I’m now thinking that it was codechef error (TLE showing up as WA). Refer to comment I added to my own question above.

I saw your code but couldn’t find the bug :frowning: Sorry

@avi224: If you cannot see the code, check the link I posted at the end of the answer as well as in the original question. Do you think I am that naive, that I will spend two days without actually reading the problem properly? If you see the code, you will find a condition that breaks and returns if 1 is not returned by the checker.
So please “Stop blaming me”. If others have also complained about the same issue, it is not like they are all mad.

I think no bug exists so you couldn’t find. Thanks for your time though. I believe it is just a codechef goof-up now that I see other posts on the forum.

@ritam777 My bad, I didn’t see your code. Are you getting WA with -1 sec or with some positive time?

WA (-1.000000) is all I see.

Hi @cenation092 thanks for the link. I am aware of that solution already, but I need help in understanding why this logic fails.

Thanks for your response. Like I said I know there are other ways, but I am curious why this solution fails. Btw I think your explanation is incorrect (though I think you have done it correctly in the contest) coz if you are saying i can calculate first four initially, that means the first four indices 1-4 have already been used up thrice in questions, so you cannot ask another question with 3, 4, 5 since 3 and 4 have appeared thrice already while finding R[1], R[2], R[3] and R[4].

@vijju123: Any response to this?

While I was not the part of panel for this contest, I can bet that its because of judge not handling all exceptions. Like, when making an interactive problem, there are several norms to adhere to, several headers of spoj to include and to use their functions for verdicts. In case the participants code does something unexpected causing your code to crash, a -1 verdict is given. And since the program crashed, you cannot count on it to give correct verdict.

Usually this means your code did something/printed something which it shouldn’t have and the judge is not handling that exception either.

(The above comment is purely my own opinion and is NOT to be taken as formal and confirmatory way of how system works)

@vijju123: What should be the next steps? Do you think it is okay to punish the participants for issues with the judge? We spend a lot of time trying to debug our code since we trust the verdict given by the judge.

I think it’s something with how judge interact with output produced in python3(Not Sure). I have 2 same solution(Algorithm wise). one in python3(AC 35 Points) and other in C++14(AC 100 Points).

  1. In python3 here
  2. In C++14 here