My solution for July challenge problem SRVRS gets “Wrong Answer” even with very simple approach - link. It generates all possible answers (vector o) and prints them from last server to first and from first CPU to last. Also I added some asserts trying to find the bug; the asserts check that all answers are different, server id and CPU id are correct, the result contains exactly Q responses. Moreover, if one line is commented, solution gets “Correct Answer” (link). The commented line in function “place” actually does not affect the answer, since it operates with variable which isn’t used here (I used it for more complicated solution). Also the correctness of operation is checked too and local variable “ans” (which is returned by the function) is marked as “const”.
Besides, the author of the problem said (via “Comments” section) that this code gets “Runtime Error” at “testing page” (Codechef online IDE?)
Usually such things are the result of undefined behaviour caused by some incorrect operation, but still can’t find it. So, can anyone please help with the following?
- What is wrong with the “Wrong Answer” solution?
- How the commented line changed it go “Correct Answer”?
- Is it actually WA or RE? What result should be displayed for interactive problems in case of RE?