You are not logged in. Please login at www.codechef.com to post your questions!

×

# Unable to find bug in SRVRS simple solution

 1 Hi @ashmelev, I faced this issue too. I used Java and not C++, but the reason is probably the same for both. As far as I understand from my own submissions, a slow solution gets a verdict of WA with execution time -1.00 sec, instead of a TLE. Your code is slow because the complexity of your code is $\mathcal{O}(N)$ per query. The ss vector is of size $N$ and you are using pop_back to empty the vectors which are elements of ss, but the loop keeps iterating over the emptied vectors for each query. Commenting the pop_back statement terminates the loop in the first iteration always, so it gets accepted. Also, you may not have faced this yet, but a few times I got WA with some positive execution time for a submission that should have got RE. So in summary, the verdicts are not what they should be. answered 19 Jul '17, 00:01 6★meooow ♦ 7.1k●7●18 accept rate: 48% 3 After quite a lot of intense debugging, I have come with the same conclusion. The judge interprets a lack of response (a TLE when it needs to read something from the contestant) as a WA (this is the way the Spoj's interface behaves). I apologise for not making an official comment during the contest. (19 Jul '17, 00:31) Yes, sometimes these servers dont give RE clearly. I was solving SPOJ GSS1 (segment tree problem) and declared array length as ~2 x10^5 instead of 4 x 10^5. Guess what? No runtime error, it went to undefined behaviour and it took me 2 days to debug (some1 else actually corrected that- i asked it on discuss after giving up) that i am getting RE due to less size. Cannot depend on judge to give correct judgement (RE or WA) atleast for C/C++ (19 Jul '17, 00:59)
 0 Q2. Undefined behaviour is very weird. Random comments can also change behaviour of code. When i got a runtime error last time, just adding a comment in last line of code changed the output from 0 to 5. It is possible that the commented line does not affect your code by any means, and source of error is somewhere else. Q3. C++ is soooo humble language, it wont trouble you with Runtime errors everytime. Instead it will just go on unstable undefined behaviour and give you heaps of WA, numerous enough to drown entire town. More formally said, do NOT depend on judge to correctly state that you got a RE or WA. Sometimes, accessing array out of bounds gave me undefined behaviour, while other times judge clearly said runtime error. I dont know why this happens, but thats how things go. Q1. Looking at your code. BTW, to detect the faulty part, just try using "/ /" to comment parts of your code, and check output on dfferent compilers OR one output without comment, another with some comments. If both the outputs are same, means the commented part has the error. Use this to narrow down to few lines and find it (i cant take a look now, will try again later tho ^^) answered 18 Jul '17, 23:19 15.4k●1●20●66 accept rate: 18% Surprisingly, there is no undefined behaviour here. I checked both @ashmelev's code and my own judge multiple times. The comment affects the running time of the algorithm. There is no memory leak of any other anomaly. The 'issue' is with the judge's message response. (19 Jul '17, 00:38) That explains why i got exact same output when i debugged it for first 25 minutes. I had a big "WTF" face and then put it off for morning thinking it must be something i am unable to grasp for now. (trust me, debugging tricky things at night can literally give headaches!!) (19 Jul '17, 00:57)
 0 Hey guys, Same kind of thing was also happening with me.. These are my two solutions in which one got accepted but other did not, And difference between two is only that I commented some section of code which was not used at all and It worked.. You can see that I am solving queries in below part of code after comment(# asking for queries), which is same in both case. And In accepted solution I have just commented a function and some variables which I was not even using. But one solution was giving WA and one was giving AC. I implemented same kind of solution in c++ too but it was giving problems there too(WA some time and AC some time). Resulting I could not move my solution further. can you guys @vijju123 @meoow @alexvaleanu help me to figure out why this was happening? Btw, In both solutions I am just storing all computers a priority queue with timeToHire as key and returning topMost PC from queue, in this basic solutions. answered 19 Jul '17, 02:48 1.1k●1●10 accept rate: 19% Sorry, i saw this post jsut now (when i was referring this link to some thread). Will look into it if you still need it. (19 Jul '17, 21:24)
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,718
×595
×21

question asked: 18 Jul '17, 20:58

question was seen: 426 times

last updated: 19 Jul '17, 21:24