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

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

C. Mahmoud and a Message

2019-11-10 20:25:06
字體:
來源:轉載
供稿:網友

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]);}


上一篇:Direct3D---紋理映射

下一篇:poj1450

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久久综合免费视频| 欧美日韩中文字幕在线| 亚洲国产天堂久久综合| 久久久久国产精品免费网站| 久久99精品久久久久久噜噜| 欧美乱妇高清无乱码| 欧洲亚洲免费视频| 欧美日韩国产色视频| 97超碰蝌蚪网人人做人人爽| 欧美在线播放视频| 欧美高清理论片| 大胆人体色综合| 亚洲欧美日本精品| 秋霞午夜一区二区| 日韩欧美国产免费播放| 深夜福利91大全| 国产精品电影网站| 久久全国免费视频| 亚洲一区二区三区视频| 欧美激情一二三| 色无极亚洲影院| 2019中文字幕全在线观看| 日韩动漫免费观看电视剧高清| 成人免费在线视频网站| 韩曰欧美视频免费观看| 久久久国产精品x99av| 国产精品欧美亚洲777777| 国产精品色悠悠| 亚洲第一区第一页| 国内精品久久久久影院 日本资源| 国产欧美精品一区二区三区介绍| 久久香蕉国产线看观看av| 91黑丝在线观看| 最近2019中文字幕一页二页| 亚洲va欧美va国产综合剧情| 国产精品xxx视频| 日韩欧美国产成人| 欧美成人精品一区二区| 在线播放精品一区二区三区| 国产精品一区久久| 欧美色播在线播放| 一本色道久久88精品综合| 国内免费久久久久久久久久久| 欧美日韩日本国产| 亚洲全黄一级网站| 国产精品一区二区三区免费视频| 国产精品激情av电影在线观看| 成人欧美一区二区三区在线| 国产精品极品尤物在线观看| 久久在精品线影院精品国产| 国产欧美一区二区三区久久人妖| 欧美精品生活片| 91超碰中文字幕久久精品| 精品性高朝久久久久久久| 97在线精品国自产拍中文| 欧美在线视频网站| 日韩激情视频在线| 日本成人激情视频| 亚洲а∨天堂久久精品喷水| 4438全国亚洲精品在线观看视频| 欧美激情a∨在线视频播放| 久久97精品久久久久久久不卡| 久久成人这里只有精品| 中文字幕亚洲二区| 亚洲第一精品夜夜躁人人躁| 国产91在线播放| 国产精品www色诱视频| 久久久久久久久久亚洲| 国产午夜精品全部视频播放| 日韩在线视频观看正片免费网站| 深夜福利一区二区| 亚洲综合精品伊人久久| 欧美超级乱淫片喷水| 久久久久久亚洲精品不卡| 欧美天天综合色影久久精品| 欧美精品精品精品精品免费| 国产午夜精品美女视频明星a级| 欧美日韩福利在线观看| 亚洲热线99精品视频| 亚洲国产精品资源| 亚洲精品在线视频| 日产精品久久久一区二区福利| 最新国产精品拍自在线播放| 日韩欧美a级成人黄色| 久久精品国产96久久久香蕉| 久久韩剧网电视剧| 欧美丝袜一区二区| 欧美在线视频免费播放| 欧美成人精品h版在线观看| 91久久精品国产91性色| 成人免费激情视频| 亚洲精品一区二区三区婷婷月| 欧美裸体xxxx| 欧美在线观看日本一区| 欧美在线视频免费播放| 久久99热这里只有精品国产| 亚洲经典中文字幕| 国产伦精品免费视频| 国产精品爽爽爽| 久久精品久久久久久国产 免费| 亚洲精品大尺度| 色阁综合伊人av| 午夜精品蜜臀一区二区三区免费| 黑人巨大精品欧美一区二区一视频| 91精品久久久久久久久久久久久久| 日韩精品免费综合视频在线播放| 久久久久久久电影一区| 国产69精品久久久久久| 色婷婷久久一区二区| 国内精品小视频在线观看| 亚州欧美日韩中文视频| 亚洲欧洲第一视频| 日韩精品免费综合视频在线播放| 国产自摸综合网| 青青在线视频一区二区三区| www.日韩视频| 日韩中文字幕在线播放| 亚洲男女性事视频| 啪一啪鲁一鲁2019在线视频| 97国产精品免费视频| 欧美性猛交视频| 国产精品在线看| 久久青草精品视频免费观看| 欧美日韩一区二区三区在线免费观看| 久久九九精品99国产精品| 九九久久国产精品| 欧美日韩在线影院| 97高清免费视频| 国产综合久久久久久| 日韩在线视频国产| 精品视频—区二区三区免费| 国产欧美精品va在线观看| 国内精品一区二区三区四区| 亚洲有声小说3d| 亚洲丝袜在线视频| 在线播放国产一区中文字幕剧情欧美| 成人a免费视频| 九九精品视频在线| 国产精品欧美日韩一区二区| 日韩高清欧美高清| 亚洲毛茸茸少妇高潮呻吟| 国产亚洲一区二区在线| 欧美在线影院在线视频| 亚洲成人网久久久| 亚洲自拍偷拍一区| 97在线观看免费高清| 亚洲国产欧美一区| 日韩成人在线网站| 日韩中文字幕免费看| 欧美大成色www永久网站婷| 国产成人久久久| 一本大道亚洲视频| 色悠悠国产精品| 久久91精品国产| 日韩亚洲精品电影| 欧美激情亚洲自拍| 影音先锋欧美精品| 国产精品久久久久9999| 欧美在线免费视频| 日韩国产在线播放| 久久91超碰青草是什么| 亚洲成人三级在线| 欧美成人精品一区二区| 国产日韩在线免费|