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

×

Help needed in Binary Matrix CF 884F

Hello, I am facing WA in test 7 in problem Binary Matrix. Here's my submission. Can anyone tell me what is wrong in my solution, or provide helpful test cases?

asked 16 Jul '18, 16:27

taran_1407's gravatar image

5★taran_1407
3.9k2387
accept rate: 22%

Can Anyone help??

(16 Jul '18, 20:11) taran_14075★
(18 Jul '18, 14:07) taran_14075★

Kept test case simple for u to debug it easily...

Saw and understood you code...

Test case :-

10 4
B
9
D
5
D
B
9
D
5
7

1011
1001
1101
0101
1101
1011
1001
1101
0101
0111

Expected Output: 1

Your output : 2

You have logical error probably....

link

answered 18 Jul '18, 16:53

l_returns's gravatar image

4★l_returns
1.4k19
accept rate: 25%

edited 18 Jul '18, 17:03

will reply error soon... I guess its related to conflicting roots or something of that type... let me check it thoroughly...
I made this test case after reading your logic...

(18 Jul '18, 16:56) l_returns4★
1

GOT ERROR

check set after
2 4
D
5

i.e.
1101
0101

so after D
set[0-3] becomes :
0012

and then you will assign
4567 to set[4-7] for 5

now for union query
union(set,3,7)

You will do find(3)
set[3]=find(set[3)) = find(2)
find(2)
set[2]=find(set[2))= find(0)
set[0]=0

so basically all will point to zero i.e set[0-3]=0000 ... which was not intended... it should remain 0012 no matter what you do...

(18 Jul '18, 17:37) l_returns4★

as I said earlier it's about conflicting and wrong assignment of value to root... Due to uniq function...

(18 Jul '18, 17:39) l_returns4★
1

Thanks a lot for test case, let me try debugging. Will ping here if can't debug.

(18 Jul '18, 17:39) taran_14075★

sure... welcome :)

(18 Jul '18, 17:57) l_returns4★

@taran_1407

https://ideone.com/CcizLE

ur code gives output 4 for this test case : :

3 16

9CFD

E9A7

9BAF

answer should be 3

hope this helps , as i don't know java so i cant figure out the bug ..

link

answered 18 Jul '18, 16:14

square_root_pi's gravatar image

0★square_root_pi
756
accept rate: 0%

edited 18 Jul '18, 16:27

1

try this one too ::

10 24

174094

882455

171152

761423

221685

761892

795431

233411

387427

793198

(18 Jul '18, 17:01) square_root_pi0★

Thanks for test cases, man.

(18 Jul '18, 17:40) taran_14075★
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
×658
×66

question asked: 16 Jul '18, 16:27

question was seen: 211 times

last updated: 18 Jul '18, 17:57