|
|
вернуться в форумHint. Послано jk_qq 17 окт 2017 13:42 Find domino with the least number of all 2*n numbers (second number have to be the biggest possible among all dominos with least first number). Let's denote minimal number as MIN and maximum as MAX. Put it in the first position with left half to be the minimal number. Then find all dominos with number more than MAX. Easy to see we already know it's orientation because of first domino (think a moment here). Put all dominos like that (use std::set<pair> or similar ds). Repeat process. Mine impl uses one set for finding first domino and one for finding all dominos with number more than current MAX. (O(N log N)) |
|
|