Unable to solve TRAINSET problem in codechef

My output is correct but codechef is showing wrong answer pls help.

Heres the link to my submission : https://www.codechef.com/viewsolution/27960335

Please either format your code or link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

2 Likes

have re-edited my post. Please help

Edit:

Thanks :slight_smile:

Consider the testcase:

1
4
boo 1
boo 1
blah 0
boo 0
2 Likes

Its giving me 4 as output that means my logic is still wrong. Thanks for your help :blush: will look into my code again

1 Like

oops sorry. Output is 4 and i think it is right but codechef still shows wrong answer

If the output is 4, what would be the contents of the Training Data Set?

1 Like

i think the contents will be still :
boo 1
boo 1
blah 0
boo 0
because i think repetition is allowed. like in case boo 1 can occur 2 times.

1 Like

And is this free of contradictions?

1 Like

yes sir i think it is free of contradictions.

In the “Example case 1” in the Problem Statement, it says: “You can include either of the first and the second item, but not both”. Why is this?

1 Like

sir i think it said that i can take abc 1 or abc 0 but not both of them together because contradictions will still happen if i choose to take both. also abc 1 and abc 1 can be put together as per the question.

And why do you think I asked that question? :slight_smile:

1 Like

sir with all due respect now i don’t know whats wrong anymore :sweat_smile:

1 Like

OK :laughing:

Here, boo is marked as “spam” twice (fine), but later it is marked as “non-spam”, a contradiction. So we cannot have this as our training set, so the answer cannot be 4 :slight_smile:

1 Like

sir what can i say you opened my eyes. Thank you so much :blush: I just started doing codechef from today itself. Feel very good on the platform. I will correct it now.

1 Like

Hello sir ! :blush: Finally i solved it. Once again thank you so much for your help.
Link to my solution : https://www.codechef.com/viewsolution/27960942

1 Like

Awesome - happy to help :slight_smile:

4 Likes

Does the absolute value symbol here indicate the length of the string wi?

1≤|wi|≤5 for each valid i

Also, are these constraints we are supposed to check, or are those constraints on the input we can expect?

Yes :slight_smile:

The latter; see my post here.

1 Like