Pagini recente » Cod sursa (job #510962) | Cod sursa (job #2708470) | Cod sursa (job #2118384) | Cod sursa (job #665315) | Cod sursa (job #253715)
Cod sursa(job #253715)
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char expresie[1001];
int n,T,q[101];
struct date {
int numar;
char sep;
};
date f[1001];
void citeste()
{
int i,tt=0,l=1;
int tmp;
while (tmp>0)
{
tmp=0;
for (i=l-1;isdigit(expresie[i]);i++)
tmp=tmp*10+expresie[i]-'0';
f[++tt].numar=tmp;
f[tt].sep=expresie[i];
if (f[tt].sep==0)
f[tt].sep='#';
l=i+2;
q[tmp]=tt;
}
q[0]=0;
f[0].sep='#';
// f[tt].sep
}
int ebun(int x,int y,int d,int T)
{
y=q[y];d=q[d];
if (f[y].sep=='#')
return 1;
if (f[y].sep=='>' && f[y+1].numar==T)
return 1;
return 0;
}
void rezolva()
{
int i,j,x=0,y,t,bun=0;
for (i=1;i<=T;i++)
{
bun=-1;
x=0;
t=0;
y=0;
for (j=1;j<=n;j++)
{
t=y;
y=x;
scanf("%d",&x);
if (ebun(x,y,t,x) && bun!=0)
bun=1;
else
{
bun=0;
}
}
if (bun)
printf("1\n");
else
printf("0\n");
}
}
int main()
{
freopen("episoade.in","r",stdin);
freopen("episoade.out","w",stdout);
// char expresie[1001];
gets(expresie);
scanf("%d %d",&T,&n);
int i;
citeste();
rezolva();
return 0;
}