結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-10-14 23:28:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 223,260 KB
最終ジャッジ日時 2023-09-08 23:58:00
合計ジャッジ時間 52,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
165,536 KB
testcase_01 AC 204 ms
165,492 KB
testcase_02 AC 694 ms
186,376 KB
testcase_03 AC 734 ms
195,500 KB
testcase_04 AC 738 ms
187,436 KB
testcase_05 AC 675 ms
179,376 KB
testcase_06 AC 781 ms
190,140 KB
testcase_07 AC 467 ms
181,460 KB
testcase_08 AC 565 ms
173,792 KB
testcase_09 AC 664 ms
192,192 KB
testcase_10 AC 577 ms
175,696 KB
testcase_11 AC 437 ms
175,920 KB
testcase_12 AC 614 ms
184,680 KB
testcase_13 AC 752 ms
199,496 KB
testcase_14 AC 689 ms
182,668 KB
testcase_15 AC 845 ms
192,240 KB
testcase_16 AC 877 ms
204,580 KB
testcase_17 AC 404 ms
176,400 KB
testcase_18 WA -
testcase_19 AC 579 ms
179,840 KB
testcase_20 AC 777 ms
202,776 KB
testcase_21 AC 705 ms
173,492 KB
testcase_22 AC 917 ms
209,668 KB
testcase_23 AC 917 ms
210,248 KB
testcase_24 AC 934 ms
209,044 KB
testcase_25 WA -
testcase_26 AC 908 ms
209,792 KB
testcase_27 AC 894 ms
209,548 KB
testcase_28 AC 909 ms
209,608 KB
testcase_29 AC 928 ms
209,244 KB
testcase_30 WA -
testcase_31 AC 904 ms
209,056 KB
testcase_32 AC 928 ms
209,296 KB
testcase_33 AC 919 ms
210,140 KB
testcase_34 AC 926 ms
209,116 KB
testcase_35 WA -
testcase_36 AC 917 ms
210,232 KB
testcase_37 AC 920 ms
210,260 KB
testcase_38 AC 903 ms
209,376 KB
testcase_39 AC 939 ms
209,532 KB
testcase_40 WA -
testcase_41 AC 932 ms
210,992 KB
testcase_42 AC 637 ms
196,140 KB
testcase_43 AC 638 ms
196,544 KB
testcase_44 AC 639 ms
196,592 KB
testcase_45 AC 648 ms
196,484 KB
testcase_46 AC 641 ms
196,476 KB
testcase_47 WA -
testcase_48 AC 523 ms
187,584 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 523 ms
187,380 KB
testcase_52 AC 333 ms
217,760 KB
testcase_53 AC 334 ms
217,736 KB
testcase_54 AC 329 ms
217,644 KB
testcase_55 AC 327 ms
170,816 KB
testcase_56 AC 328 ms
170,908 KB
testcase_57 AC 328 ms
170,676 KB
testcase_58 AC 315 ms
214,364 KB
testcase_59 AC 941 ms
223,260 KB
testcase_60 AC 508 ms
170,616 KB
testcase_61 AC 333 ms
170,640 KB
testcase_62 AC 259 ms
170,480 KB
testcase_63 AC 440 ms
169,980 KB
testcase_64 AC 444 ms
170,172 KB
testcase_65 AC 466 ms
169,956 KB
testcase_66 AC 352 ms
171,768 KB
testcase_67 AC 763 ms
170,424 KB
testcase_68 AC 326 ms
170,320 KB
testcase_69 AC 730 ms
170,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

base = 37
mod = 10**9 + 9
mod2 = 1<<63
M = 10**6+2
pows = [1]*M
for i in range(1,M-1):
    pows[i] = pows[i-1]*base%mod


hash = [set() for i in range(M)]

hash2 = [set() for i in range(M)]

n = int(input())
for _ in range(n):
    s = list(input())
    ls = len(s)
    
    find = 0
    num = 0
    num2 = 0
    for i,j in enumerate(s):
        k = ord(j)-ord("a")
        num += pows[i]*k
        num %= mod
        num2 += pows[i]*k
        num2 %= mod2

    if num in hash[ls] and num2 in hash2[ls]:
        find = 1
    
    for i in range(ls-1):
        x = ord(s[i])-ord("a")
        y = ord(s[i+1])-ord("a")

        temp = num + (y-x)*pows[i]+ (x-y)*pows[i+1]
        temp %= mod

        temp2 = num2 + (y-x)*pows[i]+ (x-y)*pows[i+1]
        temp2 %= mod2
        if temp in hash[ls] and temp2 in hash2[ls]:
            find = 1

    print("Yes" if find else "No")
    hash[ls].add(num)
    hash2[ls].add(num2)
0