結果

問題 No.1994 Confusing Name
ユーザー FromBooskaFromBooska
提出日時 2023-06-19 21:40:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 970 bytes
コンパイル時間 1,120 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 78,056 KB
最終ジャッジ日時 2023-09-09 16:49:04
合計ジャッジ時間 7,625 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,732 KB
testcase_01 AC 94 ms
71,668 KB
testcase_02 AC 98 ms
71,644 KB
testcase_03 AC 94 ms
71,460 KB
testcase_04 AC 95 ms
71,472 KB
testcase_05 AC 126 ms
77,348 KB
testcase_06 AC 147 ms
77,760 KB
testcase_07 AC 119 ms
77,664 KB
testcase_08 AC 139 ms
77,904 KB
testcase_09 AC 148 ms
78,056 KB
testcase_10 AC 131 ms
77,708 KB
testcase_11 AC 130 ms
77,536 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 長さで分けて、その中で二重ループするか
# しかしすべての長さが同じで、その中で二重ループしたらTLEするだろう

N = int(input())
from collections import defaultdict
dic_length = defaultdict(list)
dic_name = defaultdict(int)
S = []
for i in range(N):
    temp = input()
    dic_length[len(temp)].append(temp)
    dic_name[temp] = i
    
def check_sokkuri(S1, S2):
    count = 0
    for i in range(len(S1)):
        if S1[i] != S2[i]:
            count += 1
    if count == 1:
        return 1
    else:
        return 0

ans_list = [0]*N
keys = [k for k in dic_length.keys()]
for k in keys:
    l = len(dic_length[k])
    for n1 in range(l):
        for n2 in range(n1+1, l):
            if check_sokkuri(dic_length[k][n1], dic_length[k][n2]) == 1:
                ans_list[dic_name[dic_length[k][n1]]] += 1
                ans_list[dic_name[dic_length[k][n2]]] += 1

#print(ans_list)
    
for a in ans_list:
    print(a)

0