QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#116000 | #2045. Pathological Paths | NYCU_gAwr_gurA# | 100 ✓ | 6ms | 8160kb | Python3 | 1.8kb | 2023-06-27 21:31:37 | 2023-06-27 21:31:40 |
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
while True:
n, m = map(int, input().split())
if n == 0 and m == 0:
break
d = Node(None, True)
for _ in range(n):
path = input()
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(input())
p2 = split(input())
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')
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 8160kb
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...
output:
not found not found yes no yes not found yes not found yes yes not found not found not found yes not found not found not found not found not found not found yes yes yes not found not found not found not found not found not found no yes no yes no yes yes no not found
result:
ok 38 lines