In my icpc regionals they put this problem (link below), but no one came up with a correct solution that runs in time. Does anyone know a solution? The time limit is 30 seconds↵
↵
http://localdoc.scusa.lsu.edu/problems-regional/prb.php?prob=10
↵
http://localdoc.scusa.lsu.edu/problems-regional/prb.php?prob=10