-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGIT01.cpp
More file actions
68 lines (59 loc) · 1.16 KB
/
GIT01.cpp
File metadata and controls
68 lines (59 loc) · 1.16 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
57
58
59
60
61
62
63
64
65
66
67
68
#include<bits/stdc++.h>
using namespace std;
char a[101][101], temp1[101][101];
int main(){
int t,n,m,cost1=0,cost2=0;
cin >> t;
while(t--){
cin >> n >> m;
for(int i=0; i<n; ++i)
for(int j=0; j<m; ++j)
cin >> a[i][j];
//temp1[i][j] = a[i][j];
//temp2[i][j] = a[i][j];
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
if(i%2==0){
if(j%2!=0 && a[i][j] != 'G'){
//cout<<a[i][j];
//a[i][j] = 'G';
cost1+=5;
}
if(j%2==0 && a[i][j] != 'R'){
//cout<<a[i][j];
cost1+=3;
}
}
if(i%2!=0){
if(j%2==0 && a[i][j] != 'G'){
//cout<<a[i][j];
cost1+=5;
}
if(j%2!=0 && a[i][j] != 'R'){
//cout<<a[i][j];
cost1+=3;
}
}
}
//cout<<endl;
}
for(int i=0; i<n; ++i)
for(int j=0; j<m; ++j){
if(i%2 == 0){
if(j%2!=0 && a[i][j] != 'R')
cost2+=5;
if(j%2==0 && a[i][j] != 'G')
cost2+=3;
}
if(i%2!=0){
if(j%2==0 && a[i][j] != 'R')
cost2+=5;
if(j%2!=0 && a[i][j] != 'G')
cost2+=3;
}
}
cout << min(cost1,cost2)<<endl;
cost1=0;
cost2=0;
}
}