Submission #1069307

#TimeUsernameProblemLanguageResultExecution timeMemory
1069307dflsjkdfsdVlak (COCI20_vlak)Cpython 3
0 / 70
1086 ms228060 KiB
ABC = 28 MAXN = 1000010 class Node: def __init__(self): self.state = 0 self.child = [None] * ABC cnt = 0 nodes = [Node() for _ in range(MAXN * 2)] def new_node(): global cnt node = nodes[cnt] cnt += 1 return node class Trie: def __init__(self): self.root = new_node() def insert(self, node, s, pos, mask): if pos == len(s): return node.state |= mask if not node.child[ord(s[pos]) - ord('a')]: node.child[ord(s[pos]) - ord('a')] = new_node() self.insert(node.child[ord(s[pos]) - ord('a')], s, pos + 1, mask) def solve(self, node, turn): if not (node.state & (1 << turn)): return 0 for i in range(ABC): if node.child[i] and not self.solve(node.child[i], turn ^ 1): return 1 return 0 T = Trie() ans = ["Emilija", "Nina"] if __name__ == "__main__": for i in range(2): n = int(input()) for _ in range(n): s = input().strip() T.insert(T.root, s, 0, (1 << i)) print(ans[T.solve(T.root, 0)])
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...