The link I referred https://www.codechef.com/viewsolution/41274710
The type of path[i][j] is string , and the type of character[i][j] is char , you cannot do type conversion like this, One of the reason of Runtime error
You can correct it by character[i].substr(j,1);
Thanks Sir for taking out time to help me. Well, I dont understand the reason of this error. When I am running it on the sample test cases there is no such problem. And that statement is executed every time whatever input I may give. I ran it in codechef compiler…it didnt give any error …even I used compiler flags still no error…If I normally try to concatenate a character to a string that executes without any error…Would like to comment any further regarding this?
All the string handling concatenation stuff is fine, I think - if I were to guess, I’d say that the problem is mostly likely that a) the test input has extra whitespace (it’s an external contest, after all!) and b) your program can’t handle this.
For example, consider this testcase (it’s simply two copies of the sample test input, with an extra space added after the second 1 1) - this will cause your program to crash as you are not ignoring the rest of the line correctly.
To fix it, try either:
replacing cin.ignore() with cin.ignore(std::numeric_limits<streamsize>::max(), '\n'); or
taking part of @dhrub_kumar’s solution that reads input (his is whitespace-insensitive as it just reads in strings, rather than lines).