Editorial for TLE '16 Contest 1 P4 - Microwaves Again!
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For 15% of the points, choose all combinations of 3 nodes, find all nodes within a distance of 1 from these 3 nodes, sum up all microwave values, and output the maximum sum found.
For an additional 35% of the points, we can use a BFS from each node in order to get the distance between any two nodes. Next, we can use a 2-D boolean array or bitsets to keep track of whether a node is within a distance of from another node. We then choose all combinations of 3 nodes, use the boolean array/bitset to find all nodes within a distance of from these 3 nodes, sum up all microwave values, and output the maximum sum found.
For the remaining 50%, we can replace the BFS with Dijkstra or Floyd-Warshall and repeat the same bitmask procedure.
For all cases, ensure that the brute force has a low constant factor so that you will not exceed the time limit.
Time complexity:
Comments