import java.io.*; import java.util.*; import java.awt.*; class heart_judge { public Scanner sc; public PrintStream ps; public String toString() { return "heart_judge"; } public void doit() throws Exception { sc = new Scanner( System.in ); ps = System.out; // Look for nodes with available troops < k, and remove them, and remove all of their edges. // This will affect the troops of their neighbors. // Keep going until there are no more nodes with troops queue = new LinkedList(); // Go through and compute totaltroops for( int i=0; i0 ) { // Get a fallen city int city = queue.removeFirst(); // Go through its neighbors for( int neighbor=0; neighbor