about summary refs log tree commit diff
path: root/usth/MATH2.3/5/automata.c
blob: d18ca1eae80b348cfef99eabf138df3b605d55c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);

	int F[n], f[n][2];
	for (int i = 0; i < n; ++i)
		scanf("%d %d %d", F + i, f[i], f[i] + 1);

	int m;
	scanf("%d ", &m);

	char c[m + 1];
	scanf("%s", c);

	int state = 0;
	for (int i = 0; i < m; ++i)
		state = f[state][c[i] - 48];

	puts(F[state] ? "yes" : "no");

	return 0;
}