QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Difficulty: [show]

#1517. Match

統計

题目描述

有两个字符串 $s$ 和 $t$,$s$ 可能有一些位置是问号,表示尚未确定,$s$ 的其余位置和 $t$ 中的字符均为小写字母。

你需要将 $s$ 问号的位置填上小写字母,使得 $t$ 在 $s$ 中的出现次数最多。如果有多个最优解,输出任意一个。

输入格式

两行,分别输入字符串 $s$ 和 $t$。

输出格式

输出两行,第一行为 $t$ 在 $s$ 中的出现次数的最大可能值,第二行为任意一个取到这个最大值的填写后的 $s$。

样例数据

样例输入

wq?qwqs???c?c?????
qwq

样例输出

5
wqwqwqsqwqcucqwqwq

数据范围

对于所有数据,$|s|,|t|\le 10^5$。

Subtask 1(20pts):$s$ 中没有问号。

Subtask 2(10pts):$|s|,|t|\le 50$。

Subtask 3(30pts):$|s|,|t|\le 1000$。

Subtask 4(40pts):无特殊限制。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.