Hi all,
I have a few problems in this contest that I am not sure about. Can I please have some help? Thanks!
The first problem is problem B (School).
I have no idea how to do this problem. Actually, I dont really understand the question as well :(. Can someone help me?
Problem C (Dancing Lessons):
I wrote my code, but it keeps failing on testcase 11 and I dont know why. The outline of my algorithm is as follows:
First, I find all the immediate pairs of boys and girls and push them all into a set. The pairs in the set are sorted according to the conditions given.
Then, if the set is not empty:
1) I take the best pair out of the set.
2) If both members of the pair have not gone off for the dance yet, I add this person into the dance. Then, I add the pair that envelopes this pair into the set (for example, if I remove pair (4,5), I add pair (3,6) if this pair is available).
3) If one member is present, I expand it until I hit someone. Then I push it into the set.
4) If both members are gone, I just remove this pair from the set.
I keep doing this. Below is a link to my code.
http://pastebin.com/qAipmk63
Can someone help me and tell me what is wrong? :(
Thanks a lot in advance!
I have a few problems in this contest that I am not sure about. Can I please have some help? Thanks!
The first problem is problem B (School).
I have no idea how to do this problem. Actually, I dont really understand the question as well :(. Can someone help me?
Problem C (Dancing Lessons):
I wrote my code, but it keeps failing on testcase 11 and I dont know why. The outline of my algorithm is as follows:
First, I find all the immediate pairs of boys and girls and push them all into a set. The pairs in the set are sorted according to the conditions given.
Then, if the set is not empty:
1) I take the best pair out of the set.
2) If both members of the pair have not gone off for the dance yet, I add this person into the dance. Then, I add the pair that envelopes this pair into the set (for example, if I remove pair (4,5), I add pair (3,6) if this pair is available).
3) If one member is present, I expand it until I hit someone. Then I push it into the set.
4) If both members are gone, I just remove this pair from the set.
I keep doing this. Below is a link to my code.
http://pastebin.com/qAipmk63
Can someone help me and tell me what is wrong? :(
Thanks a lot in advance!
What about F (Goats and Wolves)? Do you have any idea?
My solution is different though. It is kind of a constant time solution.
http://pastebin.com/EzNPZNif