-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVestigium.java
More file actions
56 lines (56 loc) · 1.44 KB
/
Vestigium.java
File metadata and controls
56 lines (56 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.*;
import java.io.*;
public class Vestigium {
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int t = sc.nextInt();
for (int i = 1; i <= t; ++i)
{
int n=sc.nextInt();
int ar[][]=new int[n][n];
int sum=0;
for(int x=0;x<n;x++)
{
for(int y=0;y<n;y++)
{
ar[x][y]=sc.nextInt();
if(x==y)
{
sum+=ar[x][y];
}
}
}
int r=0;
int c=0;
for(int x=0;x<n;x++)
{
HashMap<Integer,Integer> hash=new HashMap<Integer,Integer>();
hash.put(ar[x][0],0);
for(int y=1;y<n;y++)
{
if(hash.containsKey(ar[x][y]))
{
r++;
break;
}
hash.put(ar[x][y],0);
}
}
for(int x=0;x<n;x++)
{
HashMap<Integer,Integer> hash=new HashMap<Integer,Integer>();
hash.put(ar[0][x],0);
for(int y=1;y<n;y++)
{
if(hash.containsKey(ar[y][x]))
{
c++;
break;
}
hash.put(ar[y][x],0);
}
}
System.out.println("Case #"+i+": "+sum+" "+r+" "+c);
}
}
}