This is the problem which I try to solve: CHFMAX
This is my code:
// code deleted
The compiler tells me Wrong Answer, but I have tested it multiple times and it seems that the output is correct. I don’t know what to do. Please tell what is wrong. Thank you!
The basic thing which I figured out from your code is that you are using short to store an integer which means that it has to be in the range -127 to 127. Here you are assigning the length of the string which could be at max 1000 to the short int. Hence the WA.
Change data type of len,i,j to int and try again.
sizeof(short) = 2, which means that this type allocates 2 bytes of memory. That means a range of [-32767, 32768] of integers. Anyway I tried to change short, but I still get WA.
take STRING_MAX_LENGTH as 1001 as last bit in character array will be assigned to null character. So if the length of string is 1000, 1000th bit will be skipped and will be assigned to null character.
That was the problem, now it works!
Thank you, vinayawsm!
You can accept the answer if it worked.
This is against the rules, I informed organizer and asked him to disqualify you. Just letting you know…
Kindly avoid asking answers during a running contest as it is against our Code Of Conduct.
Please follow the Code of Conduct, read the following link for further information: