public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); MyReader reader = new MyReader(br); MyPrinter printer = new MyPrinter(); Mice mice; String str; String output; while ((str = br.readLine()) != null) { int count = Integer.parseInt(str); for (int i = 0; i < count; i++) { int side = reader.getSide(); int[][] square = reader.getSquare(side); mice = new Mice(); output = mice.getLongestDistance(square) + ""; if (i != count - 1) { output += "\n"; } out.println(output); } } }
public void solve() throws IOException { MyReader in = new MyReader(); PrintWriter out = new PrintWriter(System.out); while (true) { int n = in.nextInt(); if (n == 0) break; int m = in.nextInt(), g = in.nextInt(), score[] = new int[m]; for (int i = 0; i < m; i++) score[i] = in.nextInt(); Student students[] = new Student[n]; for (int i = 0; i < n; i++) { String name = in.next(); int cnt = in.nextInt(), totScore = 0; for (int j = 0; j < cnt; j++) totScore += score[in.nextInt() - 1]; students[i] = new Student(name, totScore); } Arrays.sort(students); int pass_cnt = 0; for (; pass_cnt < n && students[pass_cnt].getScore() >= g; pass_cnt++) ; out.println(pass_cnt); for (int i = 0; i < pass_cnt; i++) students[i].print(out); out.flush(); } }