Help regarding MIKE3 In March challenge 2014

algorithm
mike3
wrong-answer

#1

I solved the problem MIKE3 which is giving me a correct answer for all random test cases i give to it but the OJ is giving me a WA for some reasons. here is my solution non documented version or documented version on pastebin

In the solution which is documented enough for a good understanding i have reduced the problem to find the sets of the group(offers) which cant be dealt with together and used an array named graph to store this to find the solution.

Help find the error in this algorithm/code !


#2

Approach is try all possible combination 2^20. using DP


#3

@randomizer I followed an approach similar to yours in making the m * m matrix denoting intersections but after that i used an exponential solution (of order O(m)*m ) to get the answer. here is link to my solution for reference right now. I will tell you what is wrong with your code in some time.


#4

Following assumption

//this piece finds the possible groups
which can sit starting from the [row]
which has lowest number of 1s because
it will have least number of
collisions

Looks incorrect.


#5

Your criteria for selecting the customer with minimum clash is wrong.
This the test case answer is 3. test
100 9
1 1
3 2 1 9
3 3 1 9
3 4 1 9
3 5 1 9
3 6 1 9
5 2 3 4 5 6
2 6 7
2 7 9
Your program giving 2.


#6

no i don’t want to change the approach , my algorithm looks mathematically sound to me but i want to know what went wrong


#7

What is your criteria to select a customer?


#8

Simply trying all possible combination is fine. DP is not necessary.


#9

Ya you may ignore DP part. just use recursion


#10

thanks @kcahdog


#11

can you provide me a test case which proves this ? or some proof why it will not work


#12

@randomizer I dont see any reason why you should downvote this answer. He was just trying to help. @jangwa retaliation is just as bad :smiley:


#13

Can you explain how the answer is 3 ? I believe it is 2.


#14

point taken @kcahdog


#15

Let people feel that codechef give equal right to every one. @kcahdog


#16

sorry : this is
100 9 1 1 3 2 1 9 3 3 1 9 3 4 1 9 3 5 1 9 3 6 1 9 5 2 3 4 5 6 2 6 7 2 7 9


#17

15 8 <

2 1 15 <

2 1 2 <

2 3 15 <

5 2 3 4 5 6 <

5 2 3 7 8 9 <

2 4 7 <

2 5 8 <

2 6 9 <


#18

thanks for that test case finally getting close to finally debug it :slight_smile:


#19

thanks for the test case :slight_smile: