attempt 1
This commit is contained in:
parent
106501143b
commit
bbe8222494
0
TaskF00/Makefile
Normal file
0
TaskF00/Makefile
Normal file
36
TaskF00/run
Normal file
36
TaskF00/run
Normal file
@ -0,0 +1,36 @@
|
||||
#!/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:
|
||||
tca.update(sciezki[z][char])
|
||||
except KeyError:
|
||||
pass
|
||||
act = tca;
|
||||
if len(act.intersection(stanyakceptujace))>0:
|
||||
print("YES")
|
||||
else:
|
||||
print("NO")
|
Loading…
Reference in New Issue
Block a user