結果
| 問題 |
No.8014 多項式ハッシュに関する教育的な問題
|
| ユーザー |
ちーぴん
|
| 提出日時 | 2023-10-01 15:32:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 517 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 136,064 KB |
| 最終ジャッジ日時 | 2024-07-26 13:28:12 |
| 合計ジャッジ時間 | 1,270 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 1 |
ソースコード
from sys import setrecursionlimit
setrecursionlimit(10**6)
import string
P = int(input())
B = int(input())
def hash(S):
res = 0
for s in S:
res = (res * B + s) % P
return res
D1 = {'': 0}
D2 = {}
def dfs(s):
v = (D1[s[:-1]] + ord(s[-1])) % P
D1[s] = v
if v in D2:
print(s)
print(D2[v])
exit()
else:
D2[v] = s
if len(s) == 10**4:
return
for c in string.ascii_lowercase:
dfs(s+c)
for c in string.ascii_lowercase:
dfs(c)
ちーぴん