-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion19.cpp
68 lines (44 loc) · 1.38 KB
/
Question19.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int test_case = 1;
cin >> test_case;
for(int t = 1; t <= test_case; t++){
cout <<"Case #" << t << ": ";
ll n;
cin >> n;
vector<string> upper_half(n), lower_half(n);
for(ll i = 0; i<n; i++){
cin >> upper_half[i];
}
for(ll i = 0; i<n; i++){
cin >> lower_half[i];
}
ll ans = 0;
ll upperleftI = 0, lowerleftI = 0;
for(ll i = 0; i<n; i++){
for(ll j = 0; j<n; j++){
if(upper_half[i][j] == 'I')
upperleftI++;
if(lower_half[i][j] == 'I')
lowerleftI++;
}
}
ans += (abs(upperleftI - lowerleftI));
ll upperrightI = 0, lowerrightI = 0;
for(ll i = 0; i<n; i++){
for(ll j = n; j<(2*n); j++){
if(upper_half[i][j] == 'I')
upperrightI++;
if(lower_half[i][j] == 'I')
lowerrightI++;
}
}
ans += (abs(upperrightI - lowerrightI));
cout << ans << "\n";
}
return 0;
}