diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-01-14 18:29:11 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-01-14 18:29:11 +0700 |
commit | a3dd2581ed4847670f81157091016c14ca18803d (patch) | |
tree | 3362ab15de119f1e75799f58715b7683e6bfd6ca /usth/MATH2.3/5/automata.c | |
parent | 65b8ebda4c47fa27ac28899fb2b29097f445b6df (diff) | |
download | cp-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.c | 24 |
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; +} |