https://www.codechef.com/problems/KOL16J

cplusplus

#1

#include<iostream>
using namespace std;
    int main()
    {
		int count=0,co=0;
		int a[40],i,j,k,l,t;
		int n,c=0,b=0,d;
		cin>>t;
		while(t!=0)
		{
			cin>>n;
		for(i=1;i<=n;i++)
		{
		    cin>>d;
			a[i]=d;
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				count++;
				if(a[i]==j)
				{
					i++;
				}
				else
				{
					break;
				}
			}

           int p=n;

			while(p!=0)
			{
				for(l=n;l>=1;l--)
				{
					co++;
			if(a[p]==l)
			{
				p--;
			}
			else
			{
				break;
			}
				}
				break;
			}
			int z=1;

		       while(z!=n)
		       {
				for(k=1;k<n;k++)
				{
			     	if(a[z]==a[k+1])
						{
							c+=2;
							break;
						}
			     	else
			     	{
			     		continue;
			     	}
				}
				if(c==2)
				{
					break;
		       }
		       }
             int y=1;

		       while(y!=n)
		       {
			     	if(a[y]>n)
			     	{
			     		b+=3;
			     		break;
			     	}
			     y++;
			     	if(b==3)
			     	{
			     		break;
				}
		       }

			if(c==2 || count==n)
			{
				cout<<"no";
			}
				else if( b==3 ||co==n)
				{
					cout<<"no";
				}
				else
                {
                    cout<<"yes";
                }
			break;
		}
		t--;
		}
		return 0;
		}

#2

What is your problem with this code? What does it try to do?


#3

https://www.codechef.com/problems/KOL16J