結果
問題 | No.1994 Confusing Name |
ユーザー | MasKoaTS |
提出日時 | 2022-03-30 21:34:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 903 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 463,084 KB |
最終ジャッジ日時 | 2024-04-27 11:10:06 |
合計ジャッジ時間 | 33,657 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,484 KB |
testcase_01 | AC | 39 ms
52,604 KB |
testcase_02 | AC | 38 ms
53,076 KB |
testcase_03 | AC | 38 ms
52,696 KB |
testcase_04 | AC | 37 ms
52,732 KB |
testcase_05 | AC | 84 ms
79,128 KB |
testcase_06 | AC | 98 ms
80,652 KB |
testcase_07 | AC | 55 ms
66,408 KB |
testcase_08 | AC | 98 ms
81,180 KB |
testcase_09 | AC | 98 ms
82,432 KB |
testcase_10 | AC | 92 ms
80,168 KB |
testcase_11 | AC | 81 ms
80,228 KB |
testcase_12 | AC | 1,405 ms
284,172 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 1,973 ms
364,008 KB |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | AC | 362 ms
141,752 KB |
testcase_22 | AC | 207 ms
107,060 KB |
testcase_23 | TLE | - |
testcase_24 | AC | 1,705 ms
341,384 KB |
testcase_25 | AC | 936 ms
255,592 KB |
testcase_26 | AC | 488 ms
169,368 KB |
testcase_27 | AC | 1,583 ms
325,988 KB |
testcase_28 | AC | 1,257 ms
275,728 KB |
testcase_29 | AC | 203 ms
107,860 KB |
testcase_30 | AC | 1,407 ms
284,712 KB |
ソースコード
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 = [] trie = Trie() for i in range(n): s = input().rstrip() l = [ord(c) - ord('a') for c in s] user.append(list(l)) cl = l[:]; cl[0] = 26 trie.add(cl) for j in range(1, len(cl)): cl[j - 1] = l[j - 1] cl[j] = 26 trie.add(cl) for l in user: ans = 0 cl = l[:]; cl[0] = 26 ans += trie.search(cl) - 1 for j in range(1, len(cl)): cl[j - 1] = l[j - 1] cl[j] = 26 ans += trie.search(cl) - 1 print(ans)