ABC076 C - Dubious Document 2
https://atcoder.jp/contests/abc076/tasks/abc076_c
提出
code: python
s = input()
t = input()
# まずは?を埋める <- そういうわけではない、最適な埋め方がある
# 全探索ではない
解答
code: python
s = input()
t = input()
# 辞書順の小さいものを作るためにパターンマッチは後ろから実施したいので入力を反転させる
s_r = s::-1
t_r = t::-1
ans_flag = False
# 全文字の組み合わせを試す
for i in range(len(s)):
for j in range(i+1, len(s)+1):
# tと同じ文字数の時だけ部分一致するか判定する
if (j-i) == len(t_r):
flag = True
#一文字ごとに判定する
for k,l in enumerate(range(i,j)):
if s_rl != t_rk and s_rl != '?':
flag = False
if flag == True:
#一致した位置を置換
ans = s_r:i + t_r + s_rj:
#残りの?を辞書順最小のaに置換
ans = ans.replace('?','a')
#元の順番に反転
ans = ans::-1
print(ans)
ans_flag = True
break
# forをbreakしないとcontinueする
else:
continue
break
if ans_flag == False:
print('UNRESTORABLE')
テーマ
蟻本 2-2 Best Cow Line
メモ
/yu2ta7ka/AtCoder ABC 076 C - Dubious Document 2 (300 点)