亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

C. Mahmoud and a Message

2019-11-10 19:21:59
字體:
來源:轉載
供稿:網友

C. Mahmoud and a Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mahmoud wrote a message s of length n. He wants to send it as a birthday PResent to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing the string. That's because this magical paper doesn't allow character number i in the English alphabet to be written on it in a string of length more than ai. For example, if a1?=?2 he can't write character 'a' on this paper in a string of length 3 or more. String "aa" is allowed while string "aaa" is not.

Mahmoud decided to split the message into some non-empty substrings so that he can write every substring on an independent magical paper and fulfill the condition. The sum of their lengths should be n and they shouldn't overlap. For example, if a1?=?2 and he wants to send string "aaa", he can split it into "a" and "aa" and use 2 magical papers, or into "a", "a" and "a" and use 3 magical papers. He can't split it into "aa" and "aa" because the sum of their lengths is greater than n. He can split the message into single string if it fulfills the conditions.

A substring of string s is a string that consists of some consecutive characters from string s, strings "ab", "abc" and "b" are substrings of string "abc", while strings "acb" and "ac" are not. Any string is a substring of itself.

While Mahmoud was thinking of how to split the message, Ehab told him that there are many ways to split it. After that Mahmoud asked you three questions:

How many ways are there to split the string into substrings such that every substring fulfills the condition of the magical paper, the sum of their lengths is n and they don't overlap? Compute the answer modulo 109?+?7.What is the maximum length of a substring that can appear in some valid splitting?What is the minimum number of substrings the message can be spit in?

Two ways are considered different, if the sets of split positions differ. For example, splitting "aa|a" and "a|aa" are considered different splittings of message "aaa".

Input

The first line contains an integer n (1?≤?n?≤?103) denoting the length of the message.

The second line contains the message s of length n that consists of lowercase English letters.

The third line contains 26 integers a1,?a2,?...,?a26 (1?≤?ax?≤?103) — the maximum lengths of substring each letter can appear in.

Output

Print three lines.

In the first line print the number of ways to split the message into substrings and fulfill the conditions mentioned in the problem modulo 109??+??7.

In the second line print the length of the longest substring over all the ways.

In the third line print the minimum number of substrings over all the ways.

Examplesinput
3aab2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1output
322input
10abcdeabcde5 5 5 5 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1output
40143

竟然想成了一個區間dp,直接混了,從兩邊dp去了。其實就是一個很基礎的dp。

對于新來的一個字符,新生成的子串自然就是從后面開始長度分別為1.2.3...的一些子串。

所以dp[i]表示長度為i的字符串的總的分隔方法,然后用f[i]表示分隔出的最小的子串數。

j為帶有后面新加字符的子串

從i-j+1到i的字符串合法,那么有

1.dp[i]+=dp[i-j];

2.f[i]=min(f[i],f[i-j]+1);

3.如果1~i-j的字符串也合法,那么字符串長度的最大值為max(ans,j);其實前面的必定合法。

因為長度為1的必定合法。

#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <vector>#include <queue>using namespace std;int n,m;const int MAXN=1e3+7;const int mod=1e9+7;int limit[30];long long dp[MAXN];int f[MAXN];char s[MAXN];int check(int i,int j){    int l=j-i+1;    for(int k=i;k<=j;++k)    {        if(limit[s[k]-'a']<l)return 0;    }    return 1;}int main(){    int i,j;    scanf("%d",&n);    scanf("%s",s+1);    for(i=0;i<26;++i)scanf("%d",&limit[i]);    int MAX=0;    dp[0]=1;    for(i=1;i<=n;++i)//長度為i    {        f[i]=1e9;        for(j=1;j<=i;++j)//長度        {            if(check(i-j+1,i))//后面的當前序列合法            {                dp[i]=(dp[i]+dp[i-j])%mod;                f[i]=min(f[i],f[i-j]+1);                MAX=max(MAX,j);            }        }    }    printf("%I64d/n%d/n%d/n",dp[n],MAX,f[n]);}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美性jizz18性欧美| 美女999久久久精品视频| 亚洲第一福利在线观看| 色偷偷综合社区| 欧美日韩高清在线观看| 国产午夜精品全部视频播放| 日韩视频免费大全中文字幕| 欧美黑人又粗大| 丝袜亚洲另类欧美重口| 国产精品欧美激情在线播放| 91精品久久久久久久久久久久久久| 黑人精品xxx一区| 国产盗摄xxxx视频xxx69| 精品福利免费观看| 欧美激情国产日韩精品一区18| 国产精品入口免费视频一| 91色视频在线观看| 欧美在线精品免播放器视频| 精品中文字幕在线观看| 亚洲午夜精品久久久久久性色| 97在线视频免费| 国产精品久久久久久久久久新婚| 亚洲国产精品中文| 亚洲精品自拍偷拍| 亚洲伊人一本大道中文字幕| 欧美日韩福利电影| 久久久成人av| 色婷婷久久av| 欧美高清理论片| 久久久久久国产精品久久| 国产精品小说在线| 欧美综合在线第二页| 91性高湖久久久久久久久_久久99| 最近免费中文字幕视频2019| 2025国产精品视频| 久久久人成影片一区二区三区观看| 久久婷婷国产麻豆91天堂| 45www国产精品网站| 国产欧美最新羞羞视频在线观看| 亚洲精品第一页| 欧美美女操人视频| 欧美激情18p| 日韩在线中文字幕| xxxxx成人.com| 日韩成人av网址| 欧美精品九九久久| 日韩中文字幕第一页| 美女黄色丝袜一区| 久久久爽爽爽美女图片| 亚洲第一视频在线观看| 欧美一区二区三区四区在线| 欧美国产日韩中文字幕在线| 美女福利视频一区| 国产精品精品一区二区三区午夜版| 日韩在线视频观看| 国产精品国产三级国产aⅴ9色| 影音先锋欧美在线资源| 在线视频欧美日韩精品| 久久国产一区二区三区| 7m精品福利视频导航| 91精品久久久久久久久青青| 久久久99免费视频| 久久电影一区二区| 久久精品91久久久久久再现| 91精品在线播放| 久久久国产一区| 成人精品久久一区二区三区| 亚洲成人av中文字幕| 久久精品99国产精品酒店日本| 成人福利网站在线观看11| 亚洲欧美制服第一页| 久久香蕉频线观| 国产91热爆ts人妖在线| 欧美性视频精品| 久久久久久久91| 7777kkkk成人观看| 亚洲永久免费观看| 国产精品视频一区二区三区四| 亚洲精品第一国产综合精品| 国产欧美韩国高清| 91在线观看欧美日韩| 欧美日韩精品在线观看| 热re91久久精品国99热蜜臀| 欧美午夜精品久久久久久人妖| 日韩中文字幕亚洲| 亚洲国产成人精品一区二区| 国产欧美久久久久久| 国外成人在线视频| 中文字幕日韩高清| 欧美视频一区二区三区…| 国产精品一香蕉国产线看观看| 成人黄色免费网站在线观看| 欧美激情a∨在线视频播放| 日韩视频中文字幕| 久久久久99精品久久久久| 国产精品a久久久久久| 精品久久久久久久久久久久久| 国模精品一区二区三区色天香| 久久青草精品视频免费观看| 成人a免费视频| 庆余年2免费日韩剧观看大牛| 日本精品一区二区三区在线播放视频| 日韩美女视频在线观看| 国产成人精彩在线视频九色| 91精品久久久久久久| 欧美丝袜一区二区三区| 中文字幕久久亚洲| 亚洲精品99久久久久中文字幕| 亚洲综合中文字幕在线观看| www.色综合| 最近2019年手机中文字幕| 亚洲精品自拍第一页| 高清欧美电影在线| 国产欧美一区二区白浆黑人| 国产日韩av在线播放| 91超碰caoporn97人人| 成人做爰www免费看视频网站| 国产视频在线一区二区| 欧美国产日本在线| 97香蕉久久超级碰碰高清版| 福利视频导航一区| 国产日韩欧美视频在线| 亚洲精品suv精品一区二区| 国产aⅴ夜夜欢一区二区三区| 欧美激情一区二区三区久久久| 国产中文字幕日韩| 国产97在线播放| 国内精品在线一区| 亚洲精品一区二三区不卡| 欧美激情aaaa| 欧美一区二区大胆人体摄影专业网站| 视频直播国产精品| 久久亚洲影音av资源网| 欧美日韩在线影院| 亚洲mm色国产网站| 日本在线精品视频| 久久久91精品| 亚洲三级 欧美三级| 中文字幕精品在线| 97视频国产在线| 欧美日韩一二三四五区| 国产亚洲一区二区精品| 亚洲天堂免费视频| 欧美激情xxxx| 性欧美长视频免费观看不卡| 亚洲一区亚洲二区| 国产精彩精品视频| 亚洲一区精品电影| 久久伊人91精品综合网站| 亚洲精品国产免费| 久久精品电影一区二区| 亚洲国产成人精品女人久久久| 国产不卡视频在线| 97在线视频免费播放| 夜夜躁日日躁狠狠久久88av| 在线视频欧美日韩| 亚洲高清一区二| 日韩成人在线视频观看| 欧美视频不卡中文| 亚洲老司机av| 国产精品亚洲视频在线观看| 亚洲日本成人网| 久久久久免费视频| 久久人人97超碰精品888|