Abridged problem statement To N cards, each of the front and back are red and blue, each with a number, you can choose two cards at a time, you can choose a card with a blue face number and the other card red face The result is added to your score (initial score = 0), then discard a card and put back a card until you are left with just 1 card Constraints 1 ≤ T ≤ 100. 1 ≤ R i ≤ 10 9 . 1 ≤ B i ≤ 10 9 . Small dataset 2 ≤ N ≤ 5. Large dataset 2 ≤ N ≤ 100. Approach On careful observation we observethat the minimum requirement for the sum of the weights and bounds is actually the minimum spanning tree formed by n points. Kruskal can be used to construct the MST Code # include < iostream > # include < vector > # include < set > # include < utility > # include < tuple > # include < algorithm > using namespace std ; int red [ 105 ] , blue [ 105 ] ; int union_find [ 105 ] ; int find ( int x ) ...
Solutions to all kickstart problems coming soon.