/* Sample solution for NCPC 2006: Traveling Salesman * Author: Truls A. Bjoerklund * * The solution hashes borders of all countries. It is possible * to go from one country to another if they have a border in common. * Then, the solution just uses a bfs-search. */ import java.io.*; import java.text.*; import java.util.*; public class traveling_tab { private static class Edge implements Comparable{ public int[] p1,p2; public Edge(int[] p1, int[] p2){ boolean so = true; for(int i=0;i<3;i++){ if(p1[i]> a, int f, int t){ if(f==t) return 0; ArrayList q = new ArrayList(); int[] v = new int[a.size()]; for(int i=0;i h = new HashMap(); ArrayList> n = new ArrayList>(); for(int i=0;i()); StringTokenizer st = new StringTokenizer(in.readLine()); int e = Integer.parseInt(st.nextToken()); if(e>0){ int[] last = new int[3]; int[] first = last; for(int j=0;j<3;j++) last[j]=Integer.parseInt(st.nextToken()); for(int j=1;j