CF873F.Forbidden Indices

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given a string ss consisting of nn lowercase Latin letters. Some indices in this string are marked as forbidden.

You want to find a string aa such that the value of af(a)|a|·f(a) is maximum possible, where f(a)f(a) is the number of occurences of aa in ss such that these occurences end in non-forbidden indices. So, for example, if ss is aaaa, aa is aa and index 33 is forbidden, then f(a)=2f(a)=2 because there are three occurences of aa in ss (starting in indices 11 , 22 and 33 ), but one of them (starting in index 22 ) ends in a forbidden index.

Calculate the maximum possible value of af(a)|a|·f(a) you can get.

输入格式

The first line contains an integer number nn ( 1<=n<=2000001<=n<=200000 ) — the length of ss .

The second line contains a string ss , consisting of nn lowercase Latin letters.

The third line contains a string tt , consisting of nn characters 0 and 1. If ii -th character in tt is 1, then ii is a forbidden index (otherwise ii is not forbidden).

输出格式

Print the maximum possible value of af(a)|a|·f(a) .

输入输出样例

  • 输入#1

    5
    ababa
    00100
    

    输出#1

    5
    
  • 输入#2

    5
    ababa
    00000
    

    输出#2

    6
    
  • 输入#3

    5
    ababa
    11111
    

    输出#3

    0
    
首页