結果
問題 |
No.2102 [Cherry Alpha *] Conditional Reflection
|
ユーザー |
|
提出日時 | 2022-10-16 16:16:30 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 343 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 425,308 KB |
最終ジャッジ日時 | 2024-06-27 11:31:13 |
合計ジャッジ時間 | 157,348 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 67 RE * 3 |
ソースコード
import random n = int(input()) hash_ = [random.choices(range(1, 1 << 62), k=26) for _ in range(10 ** 6)] se = [set() for _ in range(10 ** 6)] for _ in range(n): S = input() 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)