import java.io.*; import java.util.*; import java.math.*; /** * Solution to Diplomacy * * @author vanb */ public class diplomacy_vanb { public Scanner sc; public PrintStream ps; public boolean nedges[][] = new boolean[100][100]; public boolean cedges[][] = new boolean[100][100]; public int color[] = new int[100]; public int component[] = new int[100]; public int dists[][] = new int[100][100]; public int n; public int c; /** * Add a node to a connected component * * @param k Node to add to the group */ public void group( int k ) { component[k] = c; for( int i=0; i=0 && color[i]!=color[k] ) { // If node i is in a different component, make note of the edge cedges[component[i]][c] = cedges[c][component[i]] = true; } } } /** * Perform the Floyd-Warshall algorithm for all shortest paths. * * @return */ public int fw() { // Compute a Distance matrix // Use 1000 as a stand-in for infinity for( int i=0; imax && dists[i][j]<1000 ) max = dists[i][j]; } if( max