My code is running successfully in Code Blocks, but CodeChef is showing Run time error(SIGSEGV). Why is it so?
Link to my code is https://www.codechef.com/viewsolution/16746243
You default construct std::string objects in your sample1 and sample2 arrays and then later write to
sample1[j][k]='R';
sample2[j][k]='G';
But you never made sure those strings can hold at least k characters. This is undefined behavior.