From f88f391fdc935689877cf45fe6f6ef6173e3fc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kijowski=20Micha=C5=82?= Date: Fri, 1 Jan 2021 22:25:09 +0100 Subject: [PATCH] dfsgs --- TaskF01/Makefile | 0 TaskF01/run | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 TaskF01/Makefile create mode 100755 TaskF01/run diff --git a/TaskF01/Makefile b/TaskF01/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/TaskF01/run b/TaskF01/run new file mode 100755 index 0000000..ed59322 --- /dev/null +++ b/TaskF01/run @@ -0,0 +1,36 @@ +#!/usr/bin/python3 + +import sys +import re + +sciezki = {}; +stanyakceptujace = []; +f = "0 1 b\n0 0 a\n0 0 c\n1 1 b\n1 2 b\n1 2 a\n1 2 c\n2 0 a\n2 1 b\n2 0 c\n2\n"; +lines = f.splitlines(); +for line in lines: + answer = re.match('^([0-9]+) ([0-9]+) ([a-z]*)$', line); + if answer: + try: + try: + sciezki[answer.group(1)][answer.group(3)].add(answer.group(2)); + except KeyError: + sciezki[answer.group(1)][answer.group(3)] = {answer.group(2)}; + except KeyError: + sciezki.update({answer.group(1):{}}) + sciezki[answer.group(1)][answer.group(3)] = {answer.group(2)}; + else: + stanyakceptujace.append(line); +for input in sys.stdin.readlines(): + act = {str(0)}; + for char in input[:-1]: + tca = set(); + for z in act: + try: + tca.update(sciezki[z][char]); + except KeyError: + pass; + act = tca; + if len(act.intersection(stanyakceptujace))>0: + print("YES") + else: + print("NO")