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

×

Why is thIS CORRECT solution getting WA for GMEDIAN?

This is my solution which only got 5 points,I did everything right, then why I did not get 30 points? I used the Fermat Modulo Theorem to calculate (n C r) % p :- https://www.codechef.com/viewsolution/21540233

asked 13 Nov '18, 18:13

karangreat234's gravatar image

3★karangreat234
1538
accept rate: 0%

edited 13 Nov '18, 18:32


Your solution is passing only the first sub-task because it is computing the good subsequence of even length incorrectly. (There are no duplicates in the first sub-task, hence the number of good subsequence of even length is zero).

Here's a test case on which your program is failing.

1

5

1 2 2 2 3

The correct answer should be (16+8) 24, but your program falsely returns the answer as (16+6) 22.

Here's my implementation (In case you want to compare your output on custom inputs).

https://www.codechef.com/viewsolution/21520655

link

answered 13 Nov '18, 19:20

masood786's gravatar image

4★masood786
1063
accept rate: 13%

edited 13 Nov '18, 19:22

Let a1=1; a2=2; a3=2; a4=2; a5=5;

The good even subsequences are:- {2,2} {2,2} {1,2,2,3} {1,2,2,2} {1,2,2,3} {2,2,2,3}

Which are the other two I am missing ?

One of them I found out is : - {a1,a2,a4,a5}

Which is the other one I missed? Oh, I got it, its, {a2,a4}; Thankyou,verymuch!

(13 Nov '18, 20:05) karangreat2343★
toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×869
×398
×67
×9

question asked: 13 Nov '18, 18:13

question was seen: 145 times

last updated: 13 Nov '18, 20:05