結果
| 問題 | 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 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**5:
        return
    for c in string.ascii_lowercase:
        dfs(s+c)
for c in string.ascii_lowercase:
    dfs(c)
            
            
            
        