結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-10-14 23:32:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 217,764 KB
最終ジャッジ日時 2023-09-09 00:00:22
合計ジャッジ時間 59,424 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
165,428 KB
testcase_01 AC 197 ms
165,632 KB
testcase_02 AC 729 ms
181,064 KB
testcase_03 AC 751 ms
185,936 KB
testcase_04 AC 758 ms
181,044 KB
testcase_05 AC 712 ms
176,092 KB
testcase_06 AC 840 ms
183,712 KB
testcase_07 AC 468 ms
176,364 KB
testcase_08 AC 580 ms
173,052 KB
testcase_09 AC 663 ms
184,152 KB
testcase_10 AC 587 ms
173,696 KB
testcase_11 AC 439 ms
174,100 KB
testcase_12 AC 622 ms
179,756 KB
testcase_13 AC 749 ms
189,072 KB
testcase_14 AC 730 ms
178,532 KB
testcase_15 AC 910 ms
184,684 KB
testcase_16 AC 916 ms
191,436 KB
testcase_17 AC 405 ms
174,156 KB
testcase_18 WA -
testcase_19 AC 603 ms
177,100 KB
testcase_20 AC 800 ms
189,904 KB
testcase_21 AC 761 ms
172,692 KB
testcase_22 AC 956 ms
194,668 KB
testcase_23 AC 951 ms
194,912 KB
testcase_24 AC 954 ms
193,892 KB
testcase_25 WA -
testcase_26 AC 945 ms
194,732 KB
testcase_27 AC 938 ms
194,068 KB
testcase_28 AC 959 ms
193,996 KB
testcase_29 AC 999 ms
194,744 KB
testcase_30 WA -
testcase_31 AC 934 ms
194,204 KB
testcase_32 AC 950 ms
193,912 KB
testcase_33 AC 1,059 ms
194,632 KB
testcase_34 AC 943 ms
193,700 KB
testcase_35 WA -
testcase_36 AC 1,029 ms
194,772 KB
testcase_37 AC 982 ms
194,524 KB
testcase_38 AC 941 ms
193,904 KB
testcase_39 AC 979 ms
194,076 KB
testcase_40 WA -
testcase_41 AC 961 ms
195,552 KB
testcase_42 AC 678 ms
186,420 KB
testcase_43 AC 688 ms
186,420 KB
testcase_44 AC 687 ms
186,512 KB
testcase_45 AC 672 ms
186,444 KB
testcase_46 AC 679 ms
186,260 KB
testcase_47 WA -
testcase_48 AC 543 ms
180,440 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 549 ms
181,176 KB
testcase_52 AC 329 ms
217,764 KB
testcase_53 AC 330 ms
217,736 KB
testcase_54 AC 332 ms
217,648 KB
testcase_55 AC 349 ms
170,344 KB
testcase_56 AC 354 ms
170,544 KB
testcase_57 AC 351 ms
170,564 KB
testcase_58 AC 327 ms
214,272 KB
testcase_59 AC 1,005 ms
200,996 KB
testcase_60 AC 551 ms
170,468 KB
testcase_61 AC 358 ms
170,700 KB
testcase_62 AC 268 ms
170,228 KB
testcase_63 AC 474 ms
169,960 KB
testcase_64 AC 485 ms
170,080 KB
testcase_65 AC 500 ms
170,244 KB
testcase_66 AC 380 ms
171,020 KB
testcase_67 AC 852 ms
170,272 KB
testcase_68 AC 382 ms
170,388 KB
testcase_69 AC 794 ms
170,768 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,num2) in hash[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,temp2) in hash[ls]:
            find = 1

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