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

×

What's wrong with my code of CHEFHAM ?

Here is my code : code
I have got 60 pts. Actually, for n>3 I rotated the array until and unless there is an answer for that array. For n==3 i took care for that and same for n==2 and n==1. But the problem was with n==4 where there were 3 distinct elements. Please help me with this.

asked 11 Dec '17, 17:07

ashubaplawat's gravatar image

2★ashubaplawat
665
accept rate: 11%


When there are 3 distinct elements say 1,1,2,3 replace the element repeated twice with the other 2 elements and for the other 2 replace it with the repeated element.

That is 1,1,2,3 becomes : 2,3,1,1

link

answered 11 Dec '17, 17:11

sdssudhu's gravatar image

6★sdssudhu
1.1k310
accept rate: 15%

Yeah, Exactly. This is what my output was. I have taken all cases into consideration.

(11 Dec '17, 17:13) ashubaplawat2★

And my result was WA. it means it is showing some output(maybe wrong). And this is only possible when there is no match between two arrays, otherwise, it would be NZEC.

(11 Dec '17, 17:16) ashubaplawat2★

INPUT:

1

3

1 1 2

YOUR OUTPUT :

1

2 1 1

BUT

2 (here)

2 1 1

as 1->2 (1) , 1->1 (still 1) ans 2 -> 1 (2)

link

answered 11 Dec '17, 17:55

arun_001's gravatar image

4★arun_001
11
accept rate: 0%

Oh Shit, I thought we are required to maximize the index of first matching element.

(11 Dec '17, 18:26) ashubaplawat2★
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:

×858
×102

question asked: 11 Dec '17, 17:07

question was seen: 339 times

last updated: 11 Dec '17, 18:26