QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115996 | #2045. Pathological Paths | NYCU_gAwr_gurA# | 0 | 0ms | 0kb | Python3 | 1.9kb | 2023-06-27 21:27:55 | 2023-06-27 21:27:57 |
Judging History
answer
class Node:
def __init__(self, par, root = False):
self.end = False
self.cls = {
'.': self,
'..': par,
}
# if not end:
# self.cls['index.html'] = Node(self, True)
# def __repr__(self):
# return id(self)
# def __str__(self):
# s = ''
# for word in self.cls:
# s += word + '\n'
# for line in str(self.cls[word]).splitlines():
# s += ' ' + line + '\n'
# return s
def go(self, word):
if word not in self.cls:
o = Node(self)
self.cls[word] = o
return self.cls[word]
def get(self, words):
if len(words) == 0:
if self.end:
return self
return self.cls.get('index.html')
if self.end:
return None
word, *words = words
if not word:
return self.cls.get('index.html')
nxt = self.cls.get(word)
if nxt is None:
return None
return nxt.get(words)
def split(path):
words = path.split('/')[1:]
return words
with open('D.txt') as f:
while True:
n, m = map(int, f.readline().strip().split())
if n == 0 and m == 0:
break
d = Node(None, True)
for _ in range(n):
path = f.readline().strip()
words = split(path)
c = d
for word in words:
c = c.go(word)
c.end = True
# print(str(d))
for _ in range(m):
p1 = split(f.readline().strip())
p2 = split(f.readline().strip())
n1 = d.get(p1)
n2 = d.get(p2)
# print(_)
# print(p1, n1)
# print(p2, n2)
if n1 is None or n2 is None or not n1.end or not n2.end:
print('not found')
elif n1 == n2:
print('yes')
else:
print('no')
詳細信息
Test #1:
score: 0
Runtime Error
input:
5 6 /home/ACM/index.html /ICPC/index.html /ICPC/general.html /ICPC/japanese/index.html /ICPC/secret/confidential/2005/index.html /home/ACM/ /home/ICPC/../ACM/ /ICPC/secret/ /ICPC/secret/index.html /ICPC /ICPC/../ICPC/index.html /ICPC /ICPC/general.html /ICPC/japanese/.././ /ICPC/japanese/./../ /home...