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


galactik: wrong code being AC

It is quite strange that the case 5 0,-1,-1,-1,-1,-1 will give 0 while actual answer is -1..i don't think there was any constraint disallowing all negative costs or 0 connections ans still the code is AC in is the code link.

here is the link for codechef AC code

@jay_adm we want you to look into the matter and make required changes .

asked 16 Jul '13, 16:53

a9393j007's gravatar image

accept rate: 0%

edited 22 Jul '13, 05:00

gamabunta's gravatar image



I've made my own investigations on the LONG/JULY13/GALACTIK problem, and it turns out the contest test cases are really weak indeed...

At first, i must say as a disclaimer that my purpose here is not to denounce people who got AC although their implementation has some failures, but to point out the fact that test cases are weak for this specific problem. So please do not blame me for giving submission ids. :)

I only had a look on submissions in the following 3 languages :

  • C
  • Python
  • Java

Two reasons for that :

  • There are not so many submissions
  • These are languages i can partially understand

Now let's start.

Test case #1 :

3 0

Expected answer : 7

  • submissions 2335802,2335812 gave : 6 (AC ??)

Test case #2 :

1 0

Expected answer : 0

  • submissions 2339274 gave : -1 (AC ??)
  • submissions 2338565 gave : -1 (AC ??)
  • submissions 2381681,2381726,2381747,2381775,2381805 gave : -1 (AC ??)

Test case #3 :

5 0

Expected answer : -1

  • submissions 2351305 gave : 0 (AC ??)
  • submissions 2366259,2366302 gave : 0 (AC ??)
  • submissions 2340047 gave : 0 (AC ??)
  • submissions 2335888 gave nothing, as it crashed (AC ??)
  • submissions 2364389 gave : 21475336485 (AC ??)
  • submissions 2333863 gave : 0 (AC ??)
  • submissions 2382242,2382259 gave : 0 (AC ??)
  • submissions 2337394,2338695 gave : 0 (AC ??)
  • submissions 2329544,2329621,2332988 gave : 0 (AC ??)

Test case #4 :

3 2
2 3
1 2

Expected answer : 0

  • submissions 2365259,2365281,2366615 gave nothing, as it crashed (AC ??)

Test case #5 :

6 0

Expected answer : 25

  • submissions 2335802,2335812 gave : 21 (AC ??)

Test case #6 :

6 0

Expected answer : -1

  • submissions 2364389 gave : 4294967309 (AC ??)

Test case #7 :

6 4
1 2
2 5
3 4
1 6

Expected answer : 3

  • submissions 2359509 gave : 7 (AC ??)

Need to continue ?

Actually, i can see AT LEAST (as i only had a look for C, Python and Java) 15 different users that shouldn't have got AC for this problem (/!\ and i have no problem with that) if contest test cases would have been well designed. I don't know about other languages, or even other problems....

Then my question is as follow : will there be a special care taken in the future to generate very broad test cases for contests, or can we expect that kind of behaviour in the next editions ? Thank you very much for any answer or comment about that, and sorry if i seem rude to someone, it's not my intend.

Edit :

  • removed the extra spaces at the end of lines in 8th test case, removed the 5th test case (not needed anymore), and rerun local judge. i then packed some of your answers guys, as comments (to make the topic more readable)
  • removed the usernames, as they really are not needed to understand what i talk about
  • hey guys, don't worry ! as i said, it's ok for me if your code got AC without being perfect. don't feel like you have to apologize of something : you really did nothing wrong ! i could even say i'm jealous because of the luck you had ! ^^
  • i never said nor thought it would be good to rejudge all submissions for this problem. you earned these AC, so it shouldn't me removed. it would otherwise be unfair...
  • have a look at that :

answered 19 Jul '13, 03:26

cyberax's gravatar image

3★cyberax ♦
accept rate: 20%

edited 20 Jul '13, 21:25


@cyberax:seems you have spent hours to find the bugs, good spirit. In general I feel codchef is serious about test cases(some time my submission got wa due to a single tc). Hope the Admin panel, look into the matter and put proper emphasis while generating the test cases.

(19 Jul '13, 09:43) ravishanker3★

@cyberax great to see your commitment but seriously did codechef rejudge the submissions.

(19 Jul '13, 11:59) sobhagya3★

i agree with both @ravishanker and @sobhagya and you did a marvelous job and loboursome as well (Hatsoff to you)but will codechef rejudge the submissions.

(19 Jul '13, 12:56) a9393j0073★

I don't want admin to redjuge the submissions. I'm only bringing out a question which is basicly : will it happen again ? :)

(19 Jul '13, 21:21) cyberax ♦3★

@cyberax You said my 2 submissions were wrong for your test case #8. Let me tell you one thing you have given the input in wrong format. That's why the code has crashed and That is also the reason ehy codes of others even @vineetpaliwal has crashed. First you enter the input in right format and then check , because it is giving right answer on my machine when i manually enter your test case and crashes if I just copy and paste your test case.


answered 19 Jul '13, 15:00

jatin_69's gravatar image

accept rate: 0%


dude you have given input case in wrong format as there are spaces in your input where it should not be because of which my code "gave nothing, as it crashed".

(19 Jul '13, 14:52) sahil933★

Yes, the input format for the test case #5 and other test cases contains some space. That's why it shows nothing and crashed.

And i checked some of the codes and they works fine with this test case. And shocked to see @vineetpaliwal code crashed. It's working fine.

(19 Jul '13, 15:17) sobhagya3★

@cyberax : Two of your test cases contains extra spaces , and hence is improperly formatted . My code gives correct answer on both the test cases . You should please edit your post and remove my name .

(19 Jul '13, 17:45) vineetpaliwal6★

OOOPS ! Sorry, it's fixed now. Please check the post again (i've added comments at the end). thanks for pointing that out, really sorry about that, my bad.

(19 Jul '13, 21:19) cyberax ♦3★

yes these test cases were missing in the problem. One of my friends sid12 mailed this test case along with 2-3 more 5 days after the contest started. But he got a very late reply and the solutions were never rejudged.


answered 16 Jul '13, 17:08

sikander_nsit's gravatar image

accept rate: 0%

i got WA,6-7 times, checked my solutions for the mentioned corner Test cases . I am getting all the expected answers. 2369346 2363276

It is disheartening seeing the above mentioned cases of AC


answered 19 Jul '13, 03:48

pkay's gravatar image

accept rate: 33%

even i am getting correct ans for all of the above test cases ..


answered 19 Jul '13, 04:11

gauravdrocker's gravatar image

accept rate: 0%


answered 19 Jul '13, 12:05

betlista's gravatar image

3★betlista ♦♦
accept rate: 11%


thank you for the link. :) it's a quite similar question indeed.

a little difference though : i ask for a specific care to be taken to test cases, specificly not to have to redjuge all submissions. if things are done well enough from the beginning, there should be no pain afterwards, fighting with the online judge.

(19 Jul '13, 12:45) cyberax ♦3★

@cyberax Thank you for pointing my mistake. My code indeed had a bug in it. I have used a function "visit" and an array "visited" in my code. Inside the function i had mistakenly interchanged "visit" and "visited" on lines 4 and 5 so the error was generated in test case #4. The test cases for this question are indeed weak and my solution should not have got AC. However i feel rejudging all solutions would be too harsh as i was able to correct my code easily after reading this as it was a small mistake. I hope future test cases are much more exhaustive


answered 19 Jul '13, 16:21

kcahdog's gravatar image

accept rate: 14%

I don't want admin to redjuge the submissions. It would be unfair.

(19 Jul '13, 21:23) cyberax ♦3★

@cyberax Thanx for pointing out that my code had a bug......but seriously as pointed out my code gave wa for test case #3 and #7 just because of this silly mistake-"i declared cost array as long long but during scanning i was using %d format specifier for it"....why would one debug if he gets ac...i hope future test cases will be much more tricky....its disheartening for me too...seeing my name here due to a mere silly mistake.


answered 19 Jul '13, 16:54

joseph_ooooo's gravatar image

accept rate: 0%

I removed usernames for not you guys feeling bad. Sorry.

(19 Jul '13, 21:24) cyberax ♦3★
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 16 Jul '13, 16:53

question was seen: 1,953 times

last updated: 22 Jul '13, 05:00