A8123 | Mutation
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Scientists of planet Olympia are conducting an experiment in mutation of primitive organisms. Genome of organism from this planet can be represented as a string of the first $K$ capital English letters. For each pair of types of genes they assigned $a_{i,j}$ — a risk of disease occurence in the organism provided that genes of these types are adjacent in the genome, where $i$ — the 1-based index of the first gene and $j$ — the index of the second gene. The gene 'A' has index 1, 'B' has index 2 and so on. For example, $a_{3,2}$ stands for the risk of 'CB' fragment. Risk of disease occurence in the organism is equal to the sum of risks for each pair of adjacent genes in the genome.
Scientists have already obtained a base organism. Some new organisms can be obtained by mutation of this organism. Mutation involves removal of all genes of some particular types. Such removal increases the total risk of disease occurence additionally. For each type of genes scientists determined $t_{i}$ — the increasement of the total risk of disease occurence provided by removal of all genes having type with index $i$ . For example, $t_{4}$ stands for the value of additional total risk increasement in case of removing all the 'D' genes.
Scientists want to find a number of different organisms that can be obtained from the given one which have the total risk of disease occurence not greater than $T$ . They can use only the process of mutation described above. Two organisms are considered different if strings representing their genomes are different. Genome should contain at least one gene.
Scientists have already obtained a base organism. Some new organisms can be obtained by mutation of this organism. Mutation involves removal of all genes of some particular types. Such removal increases the total risk of disease occurence additionally. For each type of genes scientists determined $t_{i}$ — the increasement of the total risk of disease occurence provided by removal of all genes having type with index $i$ . For example, $t_{4}$ stands for the value of additional total risk increasement in case of removing all the 'D' genes.
Scientists want to find a number of different organisms that can be obtained from the given one which have the total risk of disease occurence not greater than $T$ . They can use only the process of mutation described above. Two organisms are considered different if strings representing their genomes are different. Genome should contain at least one gene.
输入格式
The first line of the input contains three integer numbers $N$ ( $1<=N<=200000$ ) — length of the genome of base organism, $K$ ( $1<=K<=22$ ) — the maximal index of gene type in the genome and $T$ ( $1<=T<=2·10^{9}$ ) — maximal allowable risk of disease occurence. The second line contains the genome of the given organism. It is a string of the first $K$ capital English letters having length $N$ .
The third line contains $K$ numbers $t_{1},t_{2},...,t_{K}$ , where $t_{i}$ is additional risk value of disease occurence provided by removing of all genes of the $i$ -th type.
The following $K$ lines contain the elements of the given matrix $a_{i,j}$ . The $i$ -th line contains $K$ numbers. The $j$ -th number of the $i$ -th line stands for a risk of disease occurence for the pair of genes, first of which corresponds to the $i$ -th letter and second of which corresponds to the $j$ -th letter. The given matrix is not necessarily symmetrical.
All the numbers in the input are integer, non-negative and all of them except $T$ are not greater than $10^{9}$ . It is guaranteed that the maximal possible risk of organism that can be obtained from the given organism is strictly smaller than $2^{31}$ .
The third line contains $K$ numbers $t_{1},t_{2},...,t_{K}$ , where $t_{i}$ is additional risk value of disease occurence provided by removing of all genes of the $i$ -th type.
The following $K$ lines contain the elements of the given matrix $a_{i,j}$ . The $i$ -th line contains $K$ numbers. The $j$ -th number of the $i$ -th line stands for a risk of disease occurence for the pair of genes, first of which corresponds to the $i$ -th letter and second of which corresponds to the $j$ -th letter. The given matrix is not necessarily symmetrical.
All the numbers in the input are integer, non-negative and all of them except $T$ are not greater than $10^{9}$ . It is guaranteed that the maximal possible risk of organism that can be obtained from the given organism is strictly smaller than $2^{31}$ .
输出格式
Output the number of organisms that can be obtained from the base one and which have the total risk of disease occurence not greater than $T$ .
输入输出样例
输入 #1
5 3 13 BACAC 4 1 2 1 2 3 2 3 4 3 4 10
输出 #1
5
Explanation: one can obtain the following organisms (risks are stated in brackets): BACAC (11), ACAC (10), BAA (5), B (6), AA (4).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted