結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー titiatitia
提出日時 2022-10-14 22:34:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 86,548 KB
実行使用メモリ 272,100 KB
最終ジャッジ日時 2023-09-08 22:49:32
合計ジャッジ時間 39,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
151,700 KB
testcase_01 AC 131 ms
151,824 KB
testcase_02 AC 380 ms
185,164 KB
testcase_03 AC 503 ms
190,060 KB
testcase_04 AC 434 ms
186,260 KB
testcase_05 AC 328 ms
180,164 KB
testcase_06 AC 411 ms
190,008 KB
testcase_07 AC 458 ms
206,324 KB
testcase_08 AC 244 ms
166,556 KB
testcase_09 AC 441 ms
194,348 KB
testcase_10 AC 275 ms
171,804 KB
testcase_11 AC 261 ms
170,960 KB
testcase_12 AC 349 ms
179,848 KB
testcase_13 AC 490 ms
194,776 KB
testcase_14 AC 357 ms
182,792 KB
testcase_15 AC 441 ms
193,504 KB
testcase_16 AC 528 ms
203,580 KB
testcase_17 AC 335 ms
179,632 KB
testcase_18 AC 465 ms
229,460 KB
testcase_19 AC 420 ms
174,812 KB
testcase_20 AC 516 ms
206,588 KB
testcase_21 AC 291 ms
177,072 KB
testcase_22 AC 581 ms
207,052 KB
testcase_23 AC 568 ms
207,520 KB
testcase_24 AC 561 ms
207,536 KB
testcase_25 AC 569 ms
207,200 KB
testcase_26 AC 582 ms
207,360 KB
testcase_27 AC 584 ms
207,200 KB
testcase_28 AC 582 ms
207,564 KB
testcase_29 AC 572 ms
207,352 KB
testcase_30 AC 574 ms
207,204 KB
testcase_31 AC 569 ms
207,500 KB
testcase_32 AC 571 ms
207,528 KB
testcase_33 AC 573 ms
207,288 KB
testcase_34 AC 573 ms
207,112 KB
testcase_35 AC 571 ms
207,324 KB
testcase_36 AC 578 ms
207,348 KB
testcase_37 AC 577 ms
207,200 KB
testcase_38 AC 578 ms
207,524 KB
testcase_39 AC 575 ms
207,384 KB
testcase_40 AC 575 ms
207,512 KB
testcase_41 AC 580 ms
207,048 KB
testcase_42 AC 437 ms
200,200 KB
testcase_43 AC 435 ms
200,200 KB
testcase_44 AC 430 ms
200,256 KB
testcase_45 AC 425 ms
199,852 KB
testcase_46 AC 419 ms
200,204 KB
testcase_47 AC 526 ms
256,664 KB
testcase_48 AC 518 ms
256,632 KB
testcase_49 AC 525 ms
256,932 KB
testcase_50 AC 511 ms
256,904 KB
testcase_51 AC 522 ms
256,640 KB
testcase_52 AC 505 ms
269,156 KB
testcase_53 AC 532 ms
272,100 KB
testcase_54 AC 505 ms
268,680 KB
testcase_55 AC 421 ms
249,580 KB
testcase_56 AC 424 ms
249,768 KB
testcase_57 AC 425 ms
249,836 KB
testcase_58 AC 241 ms
204,032 KB
testcase_59 AC 540 ms
226,024 KB
testcase_60 AC 230 ms
171,956 KB
testcase_61 AC 407 ms
249,288 KB
testcase_62 AC 156 ms
154,680 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 347 ms
207,140 KB
testcase_68 WA -
testcase_69 AC 346 ms
207,460 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]
        CHECKLEN[LEN].add(score2)
    
        
        
        
    
0