結果
問題 | No.8014 多項式ハッシュに関する教育的な問題 |
ユーザー |
![]() |
提出日時 | 2023-10-01 15:33:22 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 517 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,144 KB |
実行使用メモリ | 849,224 KB |
最終ジャッジ日時 | 2024-07-26 13:28:22 |
合計ジャッジ時間 | 7,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | MLE * 1 |
ソースコード
from sys import setrecursionlimitsetrecursionlimit(10**6)import stringP = int(input())B = int(input())def hash(S):res = 0for s in S:res = (res * B + s) % Preturn resD1 = {'': 0}D2 = {}def dfs(s):v = (D1[s[:-1]] + ord(s[-1])) % PD1[s] = vif v in D2:print(s)print(D2[v])exit()else:D2[v] = sif len(s) == 10**5:returnfor c in string.ascii_lowercase:dfs(s+c)for c in string.ascii_lowercase:dfs(c)