-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy patha.cc
43 lines (41 loc) · 934 Bytes
/
a.cc
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
// https://codingcompetitions.withgoogle.com/codejam/round/000000000019fd27/000000000020993c
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
int n, t;
cin >> t;
for (int T = 1; T <= t; T++) {
cin >> n;
vvi a(n, vi(n));
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
cin >> a[i][j];
int k=0, r=0, c=0;
for (int i=0; i<n; i++) {
vi s(n);
for (int j=0; j<n; j++) {
if (s[a[i][j]-1]) {
r++;
break;
}
s[a[i][j]-1]++;
}
}
for (int i=0; i<n; i++) {
vi s(n);
for (int j=0; j<n; j++) {
if (s[a[j][i]-1]) {
c++;
break;
}
s[a[j][i]-1]++;
}
}
for (int i=0; i<n; i++)
k += a[i][i];
cout << "Case #" << T << ": " << k << ' ' << r << ' ' << c << '\n';
}
}