結果
| 問題 |
No.2102 [Cherry Alpha *] Conditional Reflection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-16 16:20:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,885 ms / 3,000 ms |
| コード長 | 709 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 404,844 KB |
| 最終ジャッジ日時 | 2024-06-27 11:32:38 |
| 合計ジャッジ時間 | 27,584 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 70 |
ソースコード
import random
n = int(input())
SS = [input() for _ in range(n)]
l = max(len(S) for S in SS)
hash_ = [random.choices(range(1, 1 << 62), k=26) for _ in range(l)]
se = [set() for _ in range(l + 1)]
for S in SS:
h = 0
for i, s in enumerate(S):
h ^= hash_[i][ord(s) - 97]
l = len(S)
ans = "No"
if h in se[l]:
ans = "Yes"
else:
for i in range(l - 1):
x = 0
x ^= hash_[i][ord(S[i]) - 97]
x ^= hash_[i][ord(S[i + 1]) - 97]
x ^= hash_[i + 1][ord(S[i]) - 97]
x ^= hash_[i + 1][ord(S[i + 1]) - 97]
if h ^ x in se[l]:
ans = "Yes"
break
print(ans)
se[l].add(h)