Cod sursa(job #2785306)
| Utilizator | Data | 18 octombrie 2021 14:56:35 | |
|---|---|---|---|
| Problema | Perle | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 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()
{
for(f>>n;n;--n) {
for(f>>s[0],i=1;i<=s[0];f>>s[i],++i);
g<<(s[0]==1||B(1)==s[0]+1||C(1)==s[0]+1)<<'\n';
}
return 0;
}
