From 6ff1bc50b29b2e8854e85db6a25b2b8a052477dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kijowski=20Micha=C5=82?= Date: Fri, 1 Jan 2021 23:14:55 +0100 Subject: [PATCH] dfsgs --- TaskF04/Makefile | 0 TaskF04/run | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 TaskF04/Makefile create mode 100755 TaskF04/run diff --git a/TaskF04/Makefile b/TaskF04/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/TaskF04/run b/TaskF04/run new file mode 100755 index 0000000..1d6a0ce --- /dev/null +++ b/TaskF04/run @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +import sys +import re + +sciezki = {}; +stanyakceptujace = []; +f = open(sys.argv[1], "r"); +lines = f.readlines(); +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[:-1]); +for input in sys.stdin.readlines(): + act = {str(0)}; + for char in input[:-1]: + tca = set(); + for z in act: + try: + if sciezki[z].__contains__(''): + tca.update(sciezki[z]['']); + except KeyError: + pass; + act.update(tca); + tca = set(); + for z in act: + try: + tca.update(sciezki[z][char]); + except KeyError: + pass; + act = tca; + tca = set(); + for z in act: + try: + if sciezki[z].__contains__(''): + tca.update(sciezki[z]['']); + except KeyError: + pass; + act.update(tca); + if len(act.intersection(stanyakceptujace))>0: + print("TRUE "+input[:-1]) + else: + print("FALSE "+input[:-1])