Hello, im relatively new to cpp and codeforces. Ive been working the problem 1494A for 2 days now, but I am still failing at some testcases. I really dont want to consult the solutions. Could anyone just provide me a hint as to what im doing wrong. Any advices in general are also appreciated....
Thanks a lot. Here is my 119538142 for the problem no: 1494A - ABC String
Check if A(s) + B(s) = C(s) or otherwise
There is an issue with the way you check if the sequence is valid. For example it says "())))(((()" is valid. Other than that, everything else is fine.
How to check correct bracket sequences (here is pseudocode):
So, check all variants. But 3^50 is very big number. This optimization will help: When you paste bracket ('(' or ')') check, that bal >= 0 (If bal < 0 — break). And total bal == 0 (If bal > 0 — break). Example: