Pagini recente » Cod sursa (job #2900266) | Cod sursa (job #905327) | Cod sursa (job #1970433) | Cod sursa (job #2552203) | Cod sursa (job #1251701)
#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;
}