Cod sursa(job #1251701)

Utilizator lupuflaviu9lupuflaviu lupuflaviu9 Data 29 octombrie 2014 20:09:16
Problema Perle Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("perle.in");
ofstream g("perle.out");
int a[10001],i,k,nr,j;
int B(int x);
int C(int x);
int B(int x)
{if(a[x]==2)
return B(x+1);
if(a[x]==1&&a[x+2]==3)
return C(x+4);
return 0;
}int C(int x)
{
		
return x+1;
if(a[x]==3)
return C(B(x+1));
if(a[x]==1&&a[x+1]==2)
return x+3;
}int main()
{f>>nr;
for(j=1;j<=nr;j++)
{f>>k;
for(i=1;i<=k;i++)
f>>a[i];
if(k==1||B(1)==k+1||C(1)==k+1)
g<<1<<"\n";
else
g<<0<<"\n";
    }return 0;
}