結果
問題 |
No.2102 [Cherry Alpha *] Conditional Reflection
|
ユーザー |
![]() |
提出日時 | 2022-10-14 22:36:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 771 bytes |
コンパイル時間 | 271 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 266,024 KB |
最終ジャッジ日時 | 2024-06-26 16:11:24 |
合計ジャッジ時間 | 27,702 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 65 WA * 5 |
ソースコード
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=9007199254740997 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)