5 * @author Iskander Akishev
7 public class database_ia
implements Runnable
{
9 private static final String FILE_NAME
= "database";
14 } catch (Throwable t
) {
20 private BufferedReader in
;
21 private PrintWriter out
;
23 private void solve() throws Exception
{
24 in
= new BufferedReader(new FileReader(FILE_NAME
+ ".in"));
25 out
= new PrintWriter(new File(FILE_NAME
+ ".out"));
27 StringTokenizer st
= new StringTokenizer(in
.readLine());
28 int n
= Integer
.parseInt(st
.nextToken());
29 int m
= Integer
.parseInt(st
.nextToken());
31 String
[][] rows
= new String
[n
][m
+ 1];
33 for (int i
= 0; i
< n
; i
++) {
34 String
[] r
= in
.readLine().split(",");
35 System
.arraycopy(r
, 0, rows
[i
], 0, m
);
36 rows
[i
][m
] = Integer
.toString(i
+ 1);
39 boolean found
= false;
40 LOOP
: for (int j
= 0; j
< m
; j
++) {
41 for (int k
= j
+ 1; k
< m
; k
++) {
44 Arrays
.sort(rows
, new Comparator
<String
[]>() {
45 public int compare(String
[] o1
, String
[] o2
) {
46 int res
= o1
[jj
].compareTo(o2
[jj
]);
47 if (res
== 0) res
= o1
[kk
].compareTo(o2
[kk
]);
52 for (int i
= 1; i
< n
; i
++) {
53 if (rows
[i
- 1][j
].equals(rows
[i
][j
]) &&
54 rows
[i
- 1][k
].equals(rows
[i
][k
]))
58 out
.println(rows
[i
- 1][m
] + " " + rows
[i
][m
]);
59 out
.println((j
+ 1) + " " + (k
+ 1));
74 public static void main(String
[] args
) {
75 new Thread(new database_ia()).start();