Cod sursa(job #1321064)
Utilizator | Data | 18 ianuarie 2015 19:11:44 | |
---|---|---|---|
Problema | Perle | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.72 kb |
#include <fstream>
using namespace std;
ifstream in("perle.in");
ofstream out("perle.out");
int a[10010],n,L,B,C;
bool lmax=true;
int main()
{
in>>n;
while(n)
{
int x=0;
in>>L;
for(int i=1;i<=L;i++)
in>>a[i];
if(L==1)
out<< '1'<< "\n";
else
{
while(x<=L)
{
for(x=1;x<=L;x++)
{
if(a[x]==2)
{
B++;
x++;
}
if(a[x]==1&&a[x+2]==3)
{
if(x+4<=L){
B++;
x=x+4;}
else{
lmax=false;
B--;
}
break;
}
if(a[x]!=2 &&a[x]!=1)
{
B--;
break;
}
}
for(;x<=L;x++)
{
if(a[x]==2)
{
C++;//suspect
x++;
}
if(a[x]==3)
{
C++;
x++;
break;
}
if(a[x]==1&&a[x+1]==2)
if(x+2<=L)
{
C++;
x=x+3;
lmax=true;
break;
}
}
}
if(C>0&&B>0)
out<< '1'<< "\n";
else
out<< '0'<< "\n";
}
n--;
}
return 0;
}