CF954I.Yet Another String Matching Problem

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Suppose you have two strings ss and tt , and their length is equal. You may perform the following operation any number of times: choose two different characters c1c_{1} and c2c_{2} , and replace every occurence of c1c_{1} in both strings with c2c_{2} . Let's denote the distance between strings ss and tt as the minimum number of operations required to make these strings equal. For example, if ss is abcd and tt is ddcb, the distance between them is 22 — we may replace every occurence of a with b, so ss becomes bbcd, and then we may replace every occurence of b with d, so both strings become ddcd.

You are given two strings SS and TT . For every substring of SS consisting of T|T| characters you have to determine the distance between this substring and TT .

输入格式

The first line contains the string SS , and the second — the string TT ( 1<=T<=S<=1250001<=|T|<=|S|<=125000 ). Both strings consist of lowercase Latin letters from a to f.

输出格式

Print ST+1|S|-|T|+1 integers. The ii -th of these integers must be equal to the distance between the substring of SS beginning at ii -th index with length T|T| and the string TT .

输入输出样例

  • 输入#1

    abcdefa
    ddcb
    

    输出#1

    2 3 3 3 
    
首页