結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | roaris |
提出日時 | 2022-10-14 23:18:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,235 bytes |
コンパイル時間 | 828 ms |
コンパイル使用メモリ | 86,840 KB |
実行使用メモリ | 232,120 KB |
最終ジャッジ日時 | 2023-09-08 23:41:11 |
合計ジャッジ時間 | 29,049 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 87 ms
71,632 KB |
testcase_01 | AC | 90 ms
71,180 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 271 ms
231,924 KB |
testcase_53 | AC | 290 ms
232,120 KB |
testcase_54 | AC | 264 ms
232,032 KB |
testcase_55 | AC | 324 ms
77,864 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 328 ms
228,640 KB |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | AC | 321 ms
78,004 KB |
testcase_62 | AC | 136 ms
78,176 KB |
testcase_63 | WA | - |
testcase_64 | AC | 195 ms
78,004 KB |
testcase_65 | AC | 216 ms
78,432 KB |
testcase_66 | AC | 318 ms
77,892 KB |
testcase_67 | AC | 261 ms
78,856 KB |
testcase_68 | AC | 319 ms
77,832 KB |
testcase_69 | AC | 256 ms
79,232 KB |
ソースコード
import sys input = sys.stdin.readline from collections import * class RollingHash: def __init__(self, s): self.base = 17 self.mod = 10**9+7 self.acc = [0] self.power = [1] for i in range(len(s)): self.acc.append((self.acc[-1]*self.base%self.mod+(ord(s[i])-ord('a')))%self.mod) self.power.append(self.power[-1]*self.base%self.mod) def get(self, l, r): return (self.acc[r]-self.acc[l]*self.power[r-l])%self.mod N = int(input()) ws = set() for _ in range(N): S = input()[:-1] n = len(S) rh = RollingHash(S) h = rh.get(0, n) if h in ws: print('Yes') else: for i in range(n-1): nh = h nh -= (ord(S[i])-ord('a'))*rh.power[n-1-i]%rh.mod nh %= rh.mod nh -= (ord(S[i+1])-ord('a'))*rh.power[n-2-i]%rh.mod nh %= rh.mod nh += (ord(S[i+1])-ord('a'))*rh.power[n-1-i]%rh.mod nh %= rh.mod nh += (ord(S[i])-ord('a'))*rh.power[n-2-i]%rh.mod nh %= rh.mod if nh in ws: print('Yes') break else: print('No') ws.add(h)