# Help in Templeland

I just joined CodeChef and trying to solve Temple Land problem. The link to the problem is : https://www.codechef.com/problems/TEMPLELA. I’ve written following code for the problem :

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int Num_of_Strips;
Console.WriteLine("Enter the number of strips to look at(1<=Number of Strips<=100) : ");
int[] Num = new int[Num_of_Strips+1];
int flag = 0;
for(int i=0;i<Num_of_Strips;i++)
{
Console.WriteLine("Enter the length of Strip" + (i+1) +" : ");
Num[i + 1] = int.Parse(Console.ReadLine());
int[] height = new int[Num[i + 1]+1];
for (int j = 1; j <= Num[i + 1];j++)
{
Console.WriteLine("Enter the height of part" + j + " : ");
}
if((height[1] == 1)&&(height[Num[i + 1]] == 1))
{
if(Num[i + 1]%2 == 1)
{
int Centre_Position = (Num[i + 1] + 1) / 2;
for(int k = 1; k<= Num[i + 1];k++)
{
if((k>1) && (k<=Centre_Position))
{
if(height[k] == height[k-1]+1)
{
flag = 1;
}
else
{
flag = 0;
break;
}

}
else if((k>Centre_Position) && (k< Num[i + 1]))
{
if(height[k] == height[k-1]-1)
{
flag = 1;
}
else
{
flag = 0;
break;
}
}
}
if(flag == 0)
{
Console.WriteLine("no");
}
else
{
Console.WriteLine("yes");
}
}
else
{
Console.WriteLine("no");
}
}
else
{
Console.WriteLine("no");
}
}
}
}
}
``````

This code is working fine in my System incuding other two systems I’ve checked it with and providing correct output. Don’t know why it is giving Runtime Error(NZEC) while submitting the solution. Can anyone help me in detecting if there is any problem in the code or why it is giving such error whie uploading to codechef.

You can follow this thread and understand the possible reasons of NZEC and accordingly rectify your code.

I haven’t read all of your code so can’t tell you why you are getting NZEC.
But I’d like to point one more mistake that would lead to WA.

`````` Console.WriteLine("Enter the length of Strip" + (i+1) +" : ");
``````

Don’t print anything on the output stream other than the required answers.

``````Console.WriteLine("no");
``````

This line is OK.

I was trying to solve Temple Land program and my code worked absolutely fine in machine but when I checked on CodeChef it showed WA

``````import java.io.*;
import java.util.*;
class TEMPLELA
{ public static void main(String[] args)throws IOException
String st[]=new String[s];
int i,j;
for(i=0;i<s;i++)
StringTokenizer m=new StringTokenizer(t);
int a[]=new int[h];
for(j=0;j<h;j++)
{ a[j]=Integer.parseInt(m.nextToken());
}
if(h%2!=0)
{ if(a[0]==1)
{ int f1=0,f2=0;
for(j=0;j<h/2;j++)
{ if(a[j+1]==a[j]+1&&a[j]<a[j+1])
{f1=1;
}
else
{break;
}
}
for(j=h/2;j<h-1;j++)
{ if(a[j]==a[j+1]+1&&a[j]>a[j+1])
{ f2=1;
}
else
{break;
}
}
if(f1==1&&f2==1)
{st[i]="yes";
}
else
{ st[i]="no";
}
}
else
{st[i]="no";
}
}
else
{st[i]="no";
}
for(i=0;i<s;i++)
{ System.out.println(st[i]);
}
}
}
}
``````

can anyone help me out?? pls i am new here and need help.

I can’t understand anything… Can somebody advise me some guides or something like this, like here - grade my essay, but about java

//