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

×

KCOMPRESS Last TC

Here is link of my solution to KCOMPRESS " https://www.codechef.com/viewsolution/19705500 ".

I am somewhere stucked with the last test case.

Can someone find the testcase against which my code is not working ?

asked 13 Aug '18, 18:16

bhola_nit's gravatar image

5★bhola_nit
2015
accept rate: 0%


Try a test case like [4,4,4,3,4,4,4]. The punch line of this test case was, if there are same elements $A_i$ which are not adjacent, but within a difference of $k$ indexes, the $B_i$ assigned to them must be same.

link

answered 13 Aug '18, 19:36

vijju123's gravatar image

4★vijju123 ♦♦
15.2k11860
accept rate: 18%

exactly !!!

(13 Aug '18, 20:35) l_returns4★
1

https://www.codechef.com/viewsolution/19658864
my soln...
Prob is in cases where there are similar numbers in range....

(13 Aug '18, 20:40) l_returns4★

I disagree with @vijju123 here.
e.g. - $K = 3$
$A$ = $[1,1,1,8,1,1,1,1,9,1,1,2,3,8,3,2,1]$
$B$ = $[1,1,1,2,1,1,1,1,3,1,1,2,3,4,3,2,1]$

The punch line of this test case was, if there are same elements Ai not within a difference of k indexes, the Bi assigned to them may not be same.

link

answered 13 Aug '18, 20:41

aryanc403's gravatar image

5★aryanc403
2.3k1516
accept rate: 10%

1

if there are same elements Ai not within a difference of k indexes

Isnt this kind of obvious? How does this anyway disprove what I said? I mentioned a case when same elements lie within $k$ indices and your case is completely something else. We need to be on same platform to "disagree" or agree xD

(13 Aug '18, 21:48) vijju123 ♦♦4★

It isn't obvious. I wasted 2 days due to this. I tried with difference of 2*k earlier. And more test cases failed. Everytime I tried this I had to drop this idea. Finally used k to get AC.

(14 Aug '18, 01:45) aryanc4035★

Your code fails for test case
5 9
7 2 9 9 8
Expected Output : 2
Your Output : 3

link

answered 13 Aug '18, 21:54

vivek_shah98's gravatar image

5★vivek_shah98
966
accept rate: 0%

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:

×2,701
×398

question asked: 13 Aug '18, 18:16

question was seen: 345 times

last updated: 13 Aug '18, 21:54