結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー 👑 rin204rin204
提出日時 2022-10-16 16:20:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,147 ms / 3,000 ms
コード長 709 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 86,800 KB
実行使用メモリ 405,564 KB
最終ジャッジ日時 2023-09-09 18:56:10
合計ジャッジ時間 32,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
72,088 KB
testcase_01 AC 84 ms
72,036 KB
testcase_02 AC 291 ms
90,408 KB
testcase_03 AC 296 ms
92,992 KB
testcase_04 AC 274 ms
91,224 KB
testcase_05 AC 252 ms
88,436 KB
testcase_06 AC 285 ms
91,596 KB
testcase_07 AC 219 ms
83,360 KB
testcase_08 AC 205 ms
83,996 KB
testcase_09 AC 288 ms
90,504 KB
testcase_10 AC 216 ms
85,188 KB
testcase_11 AC 194 ms
82,636 KB
testcase_12 AC 261 ms
89,716 KB
testcase_13 AC 303 ms
93,888 KB
testcase_14 AC 264 ms
89,816 KB
testcase_15 AC 314 ms
92,832 KB
testcase_16 AC 348 ms
96,956 KB
testcase_17 AC 199 ms
81,596 KB
testcase_18 AC 258 ms
87,180 KB
testcase_19 AC 240 ms
86,728 KB
testcase_20 AC 328 ms
94,520 KB
testcase_21 AC 244 ms
86,268 KB
testcase_22 AC 370 ms
99,176 KB
testcase_23 AC 360 ms
98,380 KB
testcase_24 AC 362 ms
98,408 KB
testcase_25 AC 372 ms
99,368 KB
testcase_26 AC 361 ms
98,080 KB
testcase_27 AC 372 ms
99,228 KB
testcase_28 AC 358 ms
98,304 KB
testcase_29 AC 380 ms
98,252 KB
testcase_30 AC 368 ms
98,516 KB
testcase_31 AC 375 ms
98,176 KB
testcase_32 AC 375 ms
98,144 KB
testcase_33 AC 374 ms
99,156 KB
testcase_34 AC 368 ms
98,948 KB
testcase_35 AC 382 ms
98,520 KB
testcase_36 AC 371 ms
98,292 KB
testcase_37 AC 363 ms
97,728 KB
testcase_38 AC 377 ms
98,768 KB
testcase_39 AC 385 ms
98,252 KB
testcase_40 AC 366 ms
97,908 KB
testcase_41 AC 371 ms
98,536 KB
testcase_42 AC 287 ms
92,416 KB
testcase_43 AC 286 ms
92,656 KB
testcase_44 AC 291 ms
92,704 KB
testcase_45 AC 291 ms
92,740 KB
testcase_46 AC 287 ms
92,536 KB
testcase_47 AC 258 ms
88,712 KB
testcase_48 AC 254 ms
88,484 KB
testcase_49 AC 255 ms
88,316 KB
testcase_50 AC 255 ms
88,428 KB
testcase_51 AC 256 ms
88,096 KB
testcase_52 AC 2,147 ms
401,780 KB
testcase_53 AC 1,988 ms
405,468 KB
testcase_54 AC 1,869 ms
405,564 KB
testcase_55 AC 187 ms
79,508 KB
testcase_56 AC 184 ms
79,576 KB
testcase_57 AC 190 ms
79,772 KB
testcase_58 AC 917 ms
241,320 KB
testcase_59 AC 411 ms
105,400 KB
testcase_60 AC 180 ms
82,920 KB
testcase_61 AC 187 ms
79,508 KB
testcase_62 AC 137 ms
79,192 KB
testcase_63 AC 169 ms
81,356 KB
testcase_64 AC 168 ms
81,656 KB
testcase_65 AC 179 ms
81,808 KB
testcase_66 AC 192 ms
79,696 KB
testcase_67 AC 244 ms
86,464 KB
testcase_68 AC 182 ms
80,308 KB
testcase_69 AC 240 ms
86,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

n = int(input())
SS = [input() for _ in range(n)]
l = max(len(S) for S in SS)
hash_ = [random.choices(range(1, 1 << 62), k=26) for _ in range(l)]

se = [set() for _ in range(l + 1)]
for S in SS:
    h = 0
    for i, s in enumerate(S):
        h ^= hash_[i][ord(s) - 97]
    l = len(S)
    ans = "No"
    if h in se[l]:
        ans = "Yes"
    else:
        for i in range(l - 1):
            x = 0
            x ^= hash_[i][ord(S[i]) - 97]
            x ^= hash_[i][ord(S[i + 1]) - 97]
            x ^= hash_[i + 1][ord(S[i]) - 97]
            x ^= hash_[i + 1][ord(S[i + 1]) - 97]
            if h ^ x in se[l]:
                ans = "Yes"
                break
    print(ans)
    se[l].add(h)
0