I am trying to solve this 1234C - Pipes.
In the 5th test case, i am getting a max recursion limit exceeded error 88052124. I have tried setting the sys.setrecursionlimit and also tried solving it with C++ 88047895, and still getting the same issue. I tried generating a lot of random test cases locally to test it, however everytime it runs succesfully.
Can anyone suggest me what I am doing wrong or provide a example where my code will fail.
In the C++ version, one trick is to pass large things, like strings, by reference. Passing by copy will copy the same string onto the stack for each recursion level, while passing by reference will not, saving a lot of memory.
88059841
Notice how the only difference is
string&
instead ofstring
.