Error in Temple Land

Hello,
I joined CodeChef recently and me and my friend took part in the SnackDown Qualifiers. We were able to solve one problem, but when we submitted our project for Temple Land, it was showing wrong answer even though the entered input was the same as in the example and so was the output.
Now I find myself in a similar situation for the SnackDown Pre-Eliminator Round A where the example input and output are the same but the submission is getting declined. This time i tried writing the code in the CodeChef IDE and now am encountering this exception:

Unhandled Exception:
System.ArgumentNullException: Argument cannot be null.
Parameter name: s
  at System.Int32.Parse (System.String s) [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Argument cannot be null.
Parameter name: s
  at System.Int32.Parse (System.String s) [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 

Can someone please suggest what i should do now and explain why my sbmissions are getting declined?

Thanks.

EDIT (From Vijju123) - The link to OPs attempt is - https://www.codechef.com/viewsolution/13774712

Firstly, you dont need to check that if (a >= 1 || a <= 100), if it is mentioned in Constraints, it will be as per constraints. Secondly, even if your approach was correct your way of handling input is not.
All you’d to do was:

  1. Check if Ni is even print NO

  2. If Arr[0] and A[N-1] is not 1 print NO

  3. Iterate in a loop from 0 to N/2 and check if Arr[i+1] == Arr[i] + 1 else break and print NO

  4. Iterate from N/2 to N and check if Arr[i+1] = Arr[i] - 1 else break and print NO

  5. Print Yes if All above 4 steps failed.
    Here’s a link to my solution to help you understand the logic. Code Link

Thanks a lot for clarifying.

1 Like