Editorial for ICPC NWERC 2015 E - Elementary Math
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
- Make bipartite graph with nodes on one side, and a node for every possible answer on the other side
- Connect each pair of numbers to their possible answers
- Find a maximum matching, if this is of size we have a solution
Possible pitfalls:
- Result does not fit in an
int
- Greedy or brute force approach will not work
Comments