結果
| 問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-14 23:28:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 919 bytes |
| 記録 | |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 221,368 KB |
| 最終ジャッジ日時 | 2024-06-26 17:26:50 |
| 合計ジャッジ時間 | 51,875 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 62 WA * 8 |
ソースコード
base = 37
mod = 10**9 + 9
mod2 = 1<<63
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 in hash[ls] and num2 in hash2[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 in hash[ls] and temp2 in hash2[ls]:
find = 1
print("Yes" if find else "No")
hash[ls].add(num)
hash2[ls].add(num2)