結果
問題 | No.1994 Confusing Name |
ユーザー | MasKoaTS |
提出日時 | 2022-03-30 21:30:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,248 KB |
実行使用メモリ | 514,180 KB |
最終ジャッジ日時 | 2024-04-27 11:04:48 |
合計ジャッジ時間 | 9,389 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
60,760 KB |
testcase_01 | AC | 39 ms
53,148 KB |
testcase_02 | AC | 41 ms
53,368 KB |
testcase_03 | AC | 40 ms
52,268 KB |
testcase_04 | AC | 40 ms
52,396 KB |
testcase_05 | AC | 93 ms
79,420 KB |
testcase_06 | AC | 111 ms
80,892 KB |
testcase_07 | AC | 62 ms
66,532 KB |
testcase_08 | AC | 100 ms
81,176 KB |
testcase_09 | AC | 100 ms
82,256 KB |
testcase_10 | AC | 93 ms
80,456 KB |
testcase_11 | AC | 89 ms
80,048 KB |
testcase_12 | AC | 1,412 ms
314,932 KB |
testcase_13 | TLE | - |
testcase_14 | MLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
import sys input = sys.stdin.readline class Node: def __init__(self): self.num = 0 self.next = [None] * 27 class Trie: def __init__(self): self.root = Node() def add(self, lis): last = self.root for i in lis: if(last.next[i] is None): last.next[i] = Node() last = last.next[i] last.num += 1 def search(self, lis): last = self.root for i in lis: if(last.next[i] is None): return 0 last = last.next[i] return last.num n = 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] = 26 trie.add(cl) user[i].append(list(cl)) for j in range(1, len(cl)): cl[j - 1] = l[j - 1] cl[j] = 26 trie.add(cl) user[i].append(list(cl)) for ll in user: ans = 0 for l in ll: ans += trie.search(l) - 1 print(ans)