about summary refs log tree commit diff
path: root/usth/MATH2.3/5/automata.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2020-01-14 18:29:11 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2020-01-14 18:29:11 +0700
commita3dd2581ed4847670f81157091016c14ca18803d (patch)
tree3362ab15de119f1e75799f58715b7683e6bfd6ca /usth/MATH2.3/5/automata.c
parent65b8ebda4c47fa27ac28899fb2b29097f445b6df (diff)
downloadcp-a3dd2581ed4847670f81157091016c14ca18803d.tar.gz
[usth/MATH2.3] Mathemate Discretely
Diffstat (limited to 'usth/MATH2.3/5/automata.c')
-rw-r--r--usth/MATH2.3/5/automata.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/usth/MATH2.3/5/automata.c b/usth/MATH2.3/5/automata.c
new file mode 100644
index 0000000..d18ca1e
--- /dev/null
+++ b/usth/MATH2.3/5/automata.c
@@ -0,0 +1,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;
+}