結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-10-14 23:35:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 960 ms / 3,000 ms
コード長 954 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 218,816 KB
最終ジャッジ日時 2023-09-09 00:05:22
合計ジャッジ時間 52,960 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
154,320 KB
testcase_01 AC 203 ms
154,048 KB
testcase_02 AC 717 ms
180,360 KB
testcase_03 AC 746 ms
185,628 KB
testcase_04 AC 757 ms
181,508 KB
testcase_05 AC 708 ms
176,196 KB
testcase_06 AC 802 ms
182,928 KB
testcase_07 AC 454 ms
175,760 KB
testcase_08 AC 592 ms
174,208 KB
testcase_09 AC 651 ms
183,032 KB
testcase_10 AC 588 ms
176,256 KB
testcase_11 AC 453 ms
175,264 KB
testcase_12 AC 636 ms
180,300 KB
testcase_13 AC 723 ms
185,060 KB
testcase_14 AC 723 ms
179,012 KB
testcase_15 AC 869 ms
184,124 KB
testcase_16 AC 891 ms
190,048 KB
testcase_17 AC 402 ms
174,324 KB
testcase_18 AC 563 ms
180,340 KB
testcase_19 AC 615 ms
178,300 KB
testcase_20 AC 778 ms
188,140 KB
testcase_21 AC 766 ms
175,152 KB
testcase_22 AC 949 ms
192,568 KB
testcase_23 AC 922 ms
192,164 KB
testcase_24 AC 934 ms
192,416 KB
testcase_25 AC 947 ms
193,048 KB
testcase_26 AC 946 ms
192,056 KB
testcase_27 AC 943 ms
192,136 KB
testcase_28 AC 925 ms
192,840 KB
testcase_29 AC 951 ms
192,072 KB
testcase_30 AC 937 ms
191,832 KB
testcase_31 AC 931 ms
191,920 KB
testcase_32 AC 950 ms
192,416 KB
testcase_33 AC 939 ms
192,508 KB
testcase_34 AC 942 ms
193,608 KB
testcase_35 AC 949 ms
192,796 KB
testcase_36 AC 935 ms
192,336 KB
testcase_37 AC 934 ms
192,196 KB
testcase_38 AC 936 ms
191,912 KB
testcase_39 AC 958 ms
192,420 KB
testcase_40 AC 960 ms
193,224 KB
testcase_41 AC 936 ms
193,768 KB
testcase_42 AC 647 ms
183,972 KB
testcase_43 AC 642 ms
184,240 KB
testcase_44 AC 644 ms
184,116 KB
testcase_45 AC 643 ms
184,060 KB
testcase_46 AC 656 ms
184,436 KB
testcase_47 AC 537 ms
179,372 KB
testcase_48 AC 533 ms
179,368 KB
testcase_49 AC 530 ms
179,512 KB
testcase_50 AC 534 ms
179,284 KB
testcase_51 AC 529 ms
179,636 KB
testcase_52 AC 311 ms
218,452 KB
testcase_53 AC 314 ms
218,484 KB
testcase_54 AC 320 ms
218,284 KB
testcase_55 AC 330 ms
172,020 KB
testcase_56 AC 337 ms
172,320 KB
testcase_57 AC 331 ms
172,068 KB
testcase_58 AC 335 ms
218,816 KB
testcase_59 AC 945 ms
200,912 KB
testcase_60 AC 549 ms
173,060 KB
testcase_61 AC 331 ms
171,816 KB
testcase_62 AC 282 ms
171,680 KB
testcase_63 AC 439 ms
171,760 KB
testcase_64 AC 457 ms
170,732 KB
testcase_65 AC 471 ms
171,892 KB
testcase_66 AC 358 ms
171,440 KB
testcase_67 AC 819 ms
172,288 KB
testcase_68 AC 340 ms
171,336 KB
testcase_69 AC 814 ms
171,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
base = random.randint(30,1000)
mod = random.randint(10**7,10**15)
mod2 = 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
    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