Hints for SRM 685, D1, 250-pointer (MultiplicationTable2)

James S. Plank

Fri Apr 8 11:07:04 EDT 2016
Problem Statement.
This is a straightforward set problem.

Your approach is, for each element i, to determine the size of the good subset that contains i. You then return the minimum size subset over all elements.

Now, I did this using two sets: visited and to_visit. You start by inserting element i in to_visit. Then you go through the following loop:

This should run in roughly O(n3log(n)) time, which, for n capped at 50, is easily within topcoder's limits.