why my code is wrong

As i am new to this coding world and wrote the code what i understood from the given explanation .Can anyone pls explain me why my code is wrong? as i understood the question correctly or not?
Pls help me so that i will correct my way of analyzing the question and coding too
Pls find the question https://www…com/AUG17/problems/PALINGAM
my code https://www…com/viewsolution/14953338

Thanks in advance

You need to think more on the question. There was a much easier way to do this, and your code fails to give correct output for many cases. We need to know what did you try to do by that code to help you.

BTW, Did you try checking the editorial?? Check it out and see how it was supposed to be done. And make sure to learn from the mistake. :slight_smile:

your link does not opens edit it please

I already checked and didn’t understand why some of the submitted codes are partially right? may be i wrongly understood the subtasks can you please explain the substasks and tell me in what cases my code is wrong

I don’t have access to add code here :frowning: Can you please explain me the sub tasks of this question. I have one more doubt in the question it is mentioned that s and t have equal lengths but i saw the answers of some of the submissions even lengths are not equal are also got points. Can you please explain me how?

Constraint section means, problem setter is giving your a guarantee that “this is followed by input i have given in test cases.” If constraint says that s and t are equal, it means problem setter is telling you “I have made sure that s and t are equal in entire input.”

The game ends whenever 1 player wins. The correct direction of thinking is like this-

Lets say A has string s, and B has string t. If all characters in s are present atleast once in t, then B will win. Eg- s=“aacd” and t=“acdf”. No matter which char A chooses, B will choose the same char from his string and make it palindrome.

Eg- If A chooses to put ‘a’, then B will also put ‘a’ making the string w “aa” which is palindrome. Similar for c and d.

Just like this, you need to make cases and exhaust all possibilities. If more hint is needed, tell me. :slight_smile:

I have seen some of submissions who got 20 points and 100 points when i executed their code it is taking unequal lengths and giving outputs based on s and t strings

Subtask 1 (20 points) : 1 ≤ T ≤ 500, All characters of string s are equal, All characters of string t are equal. 1 ≤ |s| = |t| ≤ 500
Subtask 2 (80 points) : 1 ≤ T ≤ 500, 1 ≤ |s| = |t| ≤ 500

what i have understood from the above is T must be in >=1<=500 and s,t lengths must be >=1 and <=500

Pls crt me i am wrong

No, it doesnt mean that contestant must make sure. It means that the given input is of this type. “We are testing you against input which follows this constraint”

oh While coding we should may or may not include the given sub tasks right,
It is only for us to know how they test ?

Yes, its only for us to know how they test. You need not put any statements checking them. Ideally, you shouldnt.