結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-10-14 23:37:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 866 ms / 3,000 ms
コード長 761 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 218,768 KB
最終ジャッジ日時 2023-09-09 00:07:55
合計ジャッジ時間 46,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
154,412 KB
testcase_01 AC 200 ms
154,160 KB
testcase_02 AC 642 ms
178,268 KB
testcase_03 AC 657 ms
180,784 KB
testcase_04 AC 702 ms
179,068 KB
testcase_05 AC 659 ms
175,244 KB
testcase_06 AC 723 ms
180,296 KB
testcase_07 AC 412 ms
174,308 KB
testcase_08 AC 552 ms
172,952 KB
testcase_09 AC 581 ms
180,696 KB
testcase_10 AC 543 ms
174,468 KB
testcase_11 AC 425 ms
173,548 KB
testcase_12 AC 590 ms
176,288 KB
testcase_13 AC 644 ms
182,972 KB
testcase_14 AC 645 ms
176,888 KB
testcase_15 AC 763 ms
181,464 KB
testcase_16 AC 775 ms
187,000 KB
testcase_17 AC 365 ms
173,076 KB
testcase_18 AC 498 ms
178,176 KB
testcase_19 AC 584 ms
176,900 KB
testcase_20 AC 690 ms
183,736 KB
testcase_21 AC 698 ms
173,160 KB
testcase_22 AC 806 ms
186,792 KB
testcase_23 AC 826 ms
187,560 KB
testcase_24 AC 866 ms
186,880 KB
testcase_25 AC 801 ms
187,692 KB
testcase_26 AC 803 ms
187,376 KB
testcase_27 AC 817 ms
187,916 KB
testcase_28 AC 796 ms
187,068 KB
testcase_29 AC 818 ms
187,536 KB
testcase_30 AC 803 ms
187,516 KB
testcase_31 AC 809 ms
186,844 KB
testcase_32 AC 847 ms
187,108 KB
testcase_33 AC 808 ms
187,412 KB
testcase_34 AC 806 ms
187,092 KB
testcase_35 AC 819 ms
188,088 KB
testcase_36 AC 815 ms
187,880 KB
testcase_37 AC 810 ms
187,776 KB
testcase_38 AC 805 ms
187,640 KB
testcase_39 AC 863 ms
186,840 KB
testcase_40 AC 832 ms
187,484 KB
testcase_41 AC 802 ms
187,440 KB
testcase_42 AC 552 ms
181,040 KB
testcase_43 AC 578 ms
181,092 KB
testcase_44 AC 550 ms
180,956 KB
testcase_45 AC 550 ms
180,780 KB
testcase_46 AC 562 ms
180,912 KB
testcase_47 AC 453 ms
177,020 KB
testcase_48 AC 464 ms
177,288 KB
testcase_49 AC 453 ms
177,056 KB
testcase_50 AC 452 ms
177,208 KB
testcase_51 AC 452 ms
177,072 KB
testcase_52 AC 305 ms
218,260 KB
testcase_53 AC 304 ms
218,768 KB
testcase_54 AC 297 ms
218,716 KB
testcase_55 AC 289 ms
170,956 KB
testcase_56 AC 287 ms
171,224 KB
testcase_57 AC 288 ms
171,084 KB
testcase_58 AC 309 ms
218,520 KB
testcase_59 AC 834 ms
194,116 KB
testcase_60 AC 517 ms
172,860 KB
testcase_61 AC 286 ms
171,172 KB
testcase_62 AC 267 ms
171,412 KB
testcase_63 AC 393 ms
171,796 KB
testcase_64 AC 414 ms
171,396 KB
testcase_65 AC 409 ms
171,508 KB
testcase_66 AC 317 ms
173,128 KB
testcase_67 AC 715 ms
171,628 KB
testcase_68 AC 290 ms
171,972 KB
testcase_69 AC 716 ms
171,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
base = random.randint(30,1000)
mod = random.randint(10**7,10**15)
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
    for i,j in enumerate(s):
        k = ord(j)-ord("a")
        num += pows[i]*k
        num %= mod


    if num 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

        if temp in hash[ls]:
            find = 1

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