-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogle Qualification Round Problem A
120 lines (94 loc) · 2.48 KB
/
Google Qualification Round Problem A
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//#include <bits/stdc++.h>
//using namespace std;
//int main()
//{
// map< int , int >mp;
// int arr[]={5, 5 , 2 , 3};
// for(int i = 0 ; i < 4 ; i++)
// {
// mp[arr[i]]++;
// }
//
//}
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc;
cin>>tc;
int k = 1;
while(tc--)
{
int trc = 0;
int n;
cin>>n;
//map< int , int > mp;
vector< vector<int> > v;
v.resize(n,vector<int>(n));
//int *count = new int[sizeof(int)*(n)];
//unordered_map<int, int> mp;
for(int i = 0 ; i<n ; i++)
{
for(int j = 0; j<n; j++)
{
cin>>v[i][j];
if( i == j ) trc += v[i][j];
}
}
int cnt1 =0;
int cnt2 =0;
int cntTmp1 = 0;
int cntTmp2 = 0;
/// Setting Values
for (int i = 0; i < n; i++) {
cnt1 =0; cnt2 =0;
unordered_map<int, int> mpR;
unordered_map<int, int> mpC;
for (int j = 0; j < n; j++) {
mpR[v[i][j]]++;
}
for (int j = 0; j < n; j++) {
mpC[v[j][i]]++;
}
for (int j = 0; j < n; j++) {
if(mpR[v[i][j]] > 1 ) cnt1++;
}
for (int j = 0; j < n; j++) {
if(mpC[v[j][i]] > 1 ) cnt2++;
}
if(cnt1>1) cntTmp1++;
//cout<<cntTmp1<<" ";
if(cnt2>1) cntTmp2++;
//cout<<cntTmp2<<" ";
}
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < n; j++) {
// cout<<mp[v[i][j]]<<" ";
// }
// }
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//// if (itr->second % 2 == 0) {
//// int x = itr->second;
//// sum += (itr->first) * (itr->second);
//// }
//
// cout<<itr->first*<<" "<<itr->second<<endl;
// }
// }t<<endl;
cout<<"Case #"<<k++<<": "<<trc<<" "<<cntTmp1<<" "<<cntTmp2<<endl;
}
}
// for(int i = 1 ; i<=n ; i++)
// {
// for(int j = 1; j<=n; j++)
// {
// mp[v[i][j]] = 1;
//
// }
// }
// //mp[v[i][j]] = 1;
// if(mp[v[i][j]] == 1){
// cnt++;
// cout<<cnt<<" ";
// }
// else