Cod sursa(job #2781996)

Utilizator BlaugranasEnal Gemaledin Blaugranas Data 11 octombrie 2021 12:27:08
Problema Perle Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include<fstream>
using namespace std;
ifstream f("perle.in");
ofstream g("perle.out");
short n,i,s[10001];
short C(short x);
short B(short x)
{
    if(s[x]==1&&s[x+2]==3)
        return C(x+4);
    if(s[x]==2)
        return B(x+1);
    return 0;
}
short C(short x)
{
    if(s[x]==2)
        return x+1;
    if(s[x]==3)
        return C(B(x+1));
    if(s[x]==1&&s[x+1]==2)
        return x+3;
    return 0;
}
int main()
{
    f>>n;
    while(n--) {
        for(f>>s[0],i=1;i<=s[0];++i)
            f>>s[i];
        g<<(s[0]==1||B(1)==s[0]+1||C(1)==s[0]+1)<<"\n";
    }
    return 0;
}