国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

C. Mahmoud and a Message

2019-11-10 20:15:47
字體:
供稿:網(wǎng)友

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

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

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

所以dp[i]表示長度為i的字符串的總的分隔方法,然后用f[i]表示分隔出的最小的子串?dāng)?shù)。

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))//后面的當(dāng)前序列合法            {                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]);}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
中文字幕第一页av| 久久av少妇| 日本成人网址| 国产黄色免费在线观看| 在线视频1区2区| 国产日产一区二区| 丁香婷婷在线| 免费三级毛片| 国产在线你懂得| 国产区视频在线观看| 精品视频在线一区二区| 精品一区二区三区在线观看l| 丁香综合五月| 国产成人亚洲欧美电影| 精品a在线观看| 欧美性xxxx交| 国产精品久久久久久精| av资源网站在线观看| 亚洲成年人视频| 免费看的毛片| 国产变态拳头交视频一区二区| 伊人影院在线播放| 91av资源在线| 中文字幕视频在线| 精品国产福利一区二区在线| 人人干在线视频| 国产精品伦一区二区三区级视频频 | 国产激情视频在线观看| 精品无人乱码| 国产娇喘精品一区二区三区图片| 欧美性xxxx交| 中文天堂av| 国产精品18久久久久网站| 欧美日韩亚洲第一页| 国产福利av网站| 国产一级二级在线| 国产你懂的在线观看| 天堂网中文在线| 精品a在线观看| 精品国语对白精品自拍视 | 麻豆国产在线视频| av在线天堂| 亚洲国产aⅴ精品| 伊人影院蕉久影院在线播放| 黄网站在线观看高清免费| 精品日韩av| 99热播在线观看| 中文字幕av在线| 99热国产在线| 四虎一区二区三区| 久久er视频| 激情综合丁香| 国产卡二和卡三的视频| 国产精品一区二区婷婷| 高清在线观看av| 国产乱在线观看视频| 国产在线第一页| 国产丝袜精品丝袜| 精品久久亚洲一级α| 在线看黄网址| 欧美午夜电影一区二区三区| 国产精品一区二区三区高清在线| 国产香蕉尹人视频在线| 国产黄色片在线观看| 天堂√中文在线| 五月婷婷在线视频| 综合激情丁香| 国产高清一区二区三区视频| 91国内精品在线视频| 午夜羞羞小视频在线观看| 免费看av大片| 国产成人无吗| 青青草视频在线观看| 中文字幕在线视频网| 亚洲wwwwww| 国产日韩网站| 超碰免费在线| 在线国产福利网站| 国产一级视频| 免费a在线看| 在线中文视频| 高清在线观看av| 先锋av资源网| 国产porny蝌蚪视频| 免费av不卡在线观看| 国产福利图片| 五月婷婷丁香激情| 免费看ww视频网站入口| 永久免费av网站| 国产视频精品久久| 国产美女福利在线| 狠狠操视频网站| 亚洲欧美精品日韩欧美| 国产网友自拍电影在线| 免费中文字幕| 午夜羞羞小视频在线观看| 国产一级在线观看| 二人午夜免费观看在线视频| 青青草在线视频免费观看| 精品电影在线| 在线一区观看| 在线免费日韩| 在线视频色在线| 一级二级三级在线观看| 96久久久久久| 精品一区二区三区免费站| 国产三级视频在线看| 国产黄色片中文字幕| 国产黄网站在线观看| 国产高清在线看| 国产h在线观看| 精品国产美女福利到在线不卡| 91嫩草在线播放| 2019中文字幕在线电影免费| 国产无遮挡又黄又爽免费软件| 最新国产在线精品91尤物| 国产伦精品一区二区三区高清版禁| 久久99亚洲网美利坚合众国| 激情六月婷婷| 国产日本在线观看| 在线视频三区| 国内精品一区视频| 国产网友自拍视频导航网站在线观看| 国产天堂资源| 国产在线观看91| 日本一二区视频| 天堂在线亚洲| 成人午夜无人区一区二区| 久久精品国产亚洲a∨麻豆| 久久精品视频观看| 国产区高清在线| 日本免费一二区| 九九精品九九| 伊人色综合网| 国产精品你懂的在线观看| 亚洲电影先锋| 国产91在线视频蝌蚪| 精品孕妇一区二区三区| 国产成人精品实拍在线| 蜜桃av网站| 亚洲精品自拍区在线观看| 国产精品一区牛牛影视| 91中文字幕| 国产欧美在线观看视频| 人成在线免费视频| av手机免费在线观看| 国产一二区在线观看| www黄在线观看| 99色在线观看| 国产9色视频| 国产欧美日本亚洲精品一4区| 日本黄在线观看| av中文天堂在线| 伊人永久在线| 99综合精品久久| 国产福利三区| 91香蕉视频免费在线观看| 福利在线视频导航| 国产综合视频一区二区三区免费| 伊人网在线免费观看| 精品美女调教视频| 国产盗摄一区二区| 国产福利微拍精品一区二区| 国产特黄在线| 国产福利电影在线观看| 91麻豆精品国产91久久| 国产精品乱码一区二区三区视频| 大香伊人中文字幕精品| 狠狠狠狠狠狠操| 久草福利资源在线视频| 激情亚洲综合网| 国产真实伦在线观看| 开心丁香婷婷深爱五月| 丁香视频免费观看| 国产视频二区在线观看| 136福利第一导航国产在线| av二区三区| 狠狠狠狠狠狠操| √天堂8资源中文在线| 国产精品白浆流出视频| 尤物在线精品视频| 久久国产热视频| 国产网站免费观看| 伊人春色在线| 成人超碰在线| √天堂资源中文www| www.三区| 天天爱天天色| 99热播在线观看| 福利视频网站导航| 在线播放国产区| 国产一区二区三区不卡免费观看 | 午夜视频99| 一区二区三区四区在线免费视频| 免费三级毛片| 精品美女调教视频| 国产九色porn网址| www免费在线观看视频| 国产精品麻豆一区二区三区| 在线伊人免费视频|