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.
  • Make bipartite graph with n nodes on one side, and a node for every possible answer on the other side
  • Connect each pair of numbers to their 3 possible answers
  • Find a maximum matching, if this is of size n we have a solution

Possible pitfalls:

  • Result does not fit in an int
  • Greedy or brute force approach will not work

Comments

There are no comments at the moment.