This is a cakewalk problem, but, during the contest I was getting WA for it.
The reason for the WA is, I tried reading the string input using getline(cin,st) instead of just using cin. Then, I went on searching for the difference between getline and cin. I found out that, getline keeps reading the characters until a “\n” is encountered while cin reads the characters until a space is encountered i.e., cin can read words while getline reads lines (hence it can be used to read space seperated strings). So, I’m clear with this but, I still don’t understand how could this make my submission WA because the input strings are anyways gonna be in different lines.
Link to the question:
Link to my WA submission:
Link to my AC submission: