結果
問題 | No.1994 Confusing Name |
ユーザー |
![]() |
提出日時 | 2022-03-30 21:30:00 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,068 KB |
実行使用メモリ | 813,600 KB |
最終ジャッジ日時 | 2024-11-15 12:31:23 |
合計ジャッジ時間 | 37,783 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 1 |
other | AC * 15 TLE * 10 MLE * 3 |
ソースコード
import sysinput = sys.stdin.readlineclass Node:def __init__(self):self.num = 0self.next = [None] * 27class Trie:def __init__(self):self.root = Node()def add(self, lis):last = self.rootfor i in lis:if(last.next[i] is None):last.next[i] = Node()last = last.next[i]last.num += 1def search(self, lis):last = self.rootfor i in lis:if(last.next[i] is None):return 0last = last.next[i]return last.numn = int(input())user = [[] for _ in [0] * n]trie = Trie()for i in range(n):s = input().rstrip()l = [ord(c) - ord('a') for c in s]cl = l[:]; cl[0] = 26trie.add(cl)user[i].append(list(cl))for j in range(1, len(cl)):cl[j - 1] = l[j - 1]cl[j] = 26trie.add(cl)user[i].append(list(cl))for ll in user:ans = 0for l in ll:ans += trie.search(l) - 1print(ans)