#include <iostream>
using namespace std;
int main() {
// your code goes here'
int r,c,testcase,min,cost;
cost = 0;
cin >> testcase;
char start_r,start_c;
for (int i = 0; i <testcase; i++)
{
cin >> r >> c;
char orginal[r][c],fake[r][c];
for ( int i =0 ; i<r ; i++){
cin>>fake[i];
}
min = 0;
start_r = 'R';
for (int i=0;i<r;i++){
start_c = start_r;
for(int j=0;j<c;j++){
orginal[i][j] = start_c;
if (start_c == 'G'){
start_c = 'R';
}
else
{
start_c = 'G';
}
if (fake[i][j] != orginal[i][j]){
if (fake[i][j] == 'R'){
cost = cost + 3;
}
else{
cost = cost + 5;
}
}
}
if (start_r=='R'){
start_r = 'G';
}
else
{
start_r='R';
}
}
min = cost;
cost = 0;
start_r = 'G';
for (int i=0;i<r;i++){
start_c = start_r;
for(int j=0;j<c;j++){
orginal[i][j] = start_c;
if (start_c == 'G'){
start_c = 'R';
}
else
{
start_c = 'G';
}
if (fake[i][j] != orginal[i][j]){
if (fake[i][j] == 'R'){
cost = cost + 3;
}
else{
cost = cost + 5;
}
}
}
if (start_r=='R'){
start_r = 'G';
}
else
{
start_r='R';
}
}
if (min < cost){
cout<<min<<"\n";
}
else{
cout<<cost<<"\n";
}
}
return 0;
}
**Above is my code which runs fine on my desktop but on codechef compiler it gives this error “sigsegv” … Please help **