結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー titiatitia
提出日時 2022-10-14 22:45:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 488 ms / 3,000 ms
コード長 840 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 269,744 KB
最終ジャッジ日時 2023-09-08 23:07:00
合計ジャッジ時間 31,980 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
152,048 KB
testcase_01 AC 115 ms
151,892 KB
testcase_02 AC 325 ms
185,332 KB
testcase_03 AC 362 ms
190,848 KB
testcase_04 AC 322 ms
186,992 KB
testcase_05 AC 281 ms
180,668 KB
testcase_06 AC 333 ms
190,460 KB
testcase_07 AC 370 ms
207,232 KB
testcase_08 AC 209 ms
166,704 KB
testcase_09 AC 368 ms
194,488 KB
testcase_10 AC 234 ms
172,388 KB
testcase_11 AC 221 ms
171,784 KB
testcase_12 AC 296 ms
180,196 KB
testcase_13 AC 407 ms
195,420 KB
testcase_14 AC 305 ms
183,312 KB
testcase_15 AC 373 ms
193,892 KB
testcase_16 AC 432 ms
204,216 KB
testcase_17 AC 277 ms
180,380 KB
testcase_18 AC 394 ms
229,816 KB
testcase_19 AC 258 ms
175,288 KB
testcase_20 AC 416 ms
207,852 KB
testcase_21 AC 251 ms
177,296 KB
testcase_22 AC 465 ms
207,568 KB
testcase_23 AC 464 ms
207,788 KB
testcase_24 AC 468 ms
207,568 KB
testcase_25 AC 468 ms
207,632 KB
testcase_26 AC 461 ms
207,412 KB
testcase_27 AC 468 ms
207,792 KB
testcase_28 AC 465 ms
207,776 KB
testcase_29 AC 475 ms
207,636 KB
testcase_30 AC 488 ms
207,440 KB
testcase_31 AC 472 ms
207,784 KB
testcase_32 AC 478 ms
207,912 KB
testcase_33 AC 476 ms
207,936 KB
testcase_34 AC 477 ms
207,836 KB
testcase_35 AC 469 ms
207,708 KB
testcase_36 AC 474 ms
207,708 KB
testcase_37 AC 475 ms
207,716 KB
testcase_38 AC 468 ms
207,696 KB
testcase_39 AC 466 ms
207,600 KB
testcase_40 AC 468 ms
207,420 KB
testcase_41 AC 488 ms
207,408 KB
testcase_42 AC 347 ms
200,444 KB
testcase_43 AC 351 ms
200,524 KB
testcase_44 AC 352 ms
200,464 KB
testcase_45 AC 348 ms
200,464 KB
testcase_46 AC 350 ms
200,264 KB
testcase_47 AC 398 ms
256,892 KB
testcase_48 AC 391 ms
256,888 KB
testcase_49 AC 395 ms
256,992 KB
testcase_50 AC 397 ms
257,000 KB
testcase_51 AC 397 ms
256,976 KB
testcase_52 AC 385 ms
268,980 KB
testcase_53 AC 380 ms
269,440 KB
testcase_54 AC 383 ms
269,744 KB
testcase_55 AC 331 ms
249,664 KB
testcase_56 AC 332 ms
250,076 KB
testcase_57 AC 327 ms
249,616 KB
testcase_58 AC 215 ms
203,972 KB
testcase_59 AC 440 ms
226,004 KB
testcase_60 AC 213 ms
172,432 KB
testcase_61 AC 327 ms
249,872 KB
testcase_62 AC 147 ms
155,284 KB
testcase_63 AC 240 ms
196,904 KB
testcase_64 AC 243 ms
197,004 KB
testcase_65 AC 247 ms
196,820 KB
testcase_66 AC 336 ms
250,024 KB
testcase_67 AC 307 ms
207,860 KB
testcase_68 AC 206 ms
193,060 KB
testcase_69 AC 312 ms
207,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
S=[list(input().strip()) for i in range(N)]

# Rolling Hash
LEN=len(S)

p=26 # 文字の種類
mod=(1<<50)+1 # Hashがぶつからない, pと互いに素な数を適当に指定

MAX=0
for s in S:
    MAX=max(MAX,len(s))

CHECKLEN=[set() for i in range(MAX+1)]
POWP=[1]
for i in range(10**6+1):
    POWP.append(POWP[-1]*p%mod)

for s in S:
    LEN=len(s)
    
    score=0
    for i in range(LEN):
        score=(score+(ord(s[i])-97)*POWP[i])%mod

    if score in CHECKLEN[LEN]:
        print("Yes")
    else:
        print("No")

    CHECKLEN[LEN].add(score)

    for i in range(LEN-1):
        score2=(score-(ord(s[i])-97)*POWP[i]-(ord(s[i+1])-97)*POWP[i+1]+(ord(s[i+1])-97)*POWP[i]+(ord(s[i])-97)*POWP[i+1])%mod
        CHECKLEN[LEN].add(score2)
    
        
        
        
    
0