时间限制: 1 Sec  内存限制: 128 MB
提交: 31  解决: 12
[提交] [状态] [命题人:admin]

题目描述

Leila is a Bioinformatician, interested in studying Bacterial evolution. In one experiment on a special type of Bacteria,she started from a single bacterium, put it on a plate, and monitored the bacterial division, until she obtained a population of k bacteria. During the process, she carefully reported the evolutionary relations between bacteria. Precisely, for each bacterium, she reported its parent bacterium.
In the next step, she extracted DNA sequences of k bacteria in the final population, by NGS technology. Each DNA sequence is represented as a string of length m from the alphabet set { A, T, C, G }.
The NGS technology has a drawback: it produces a lot of missing values. So, there are a lot of unknown characters indicated by ‘?’ in the extracted sequences. Considering the evolutionary relationship between bacteria, Leila wants to impute the missing values. Among all possible imputations, she wants to find the minimum cost imputation from an evolutionary perspective.
The problem is defined as follows. A rooted tree T is given, and for each leaf v of T, a string b v of length m from the character set { A, T, C, G, ? } is given. A transition cost matrix ∆ is also given, where ∆(x, y) (x, y ∈ { A, T, C, G }) represents the cost of a transition from an x character to a y character, from a parent to its child.
A feasible imputation, assigns a string s u of length m from the character set { A, T, C, G } to each vertex u, where for each leaf v of T, sv is equal to b v except for ‘?’ characters in bv . The evolutionary cost of an imputation is defined as the sum of evolutionary costs of all edges. The evolutionary cost of an edge between parent u and child w, is defined as , where su[i] is the i-th character of su.
Leila wants to find a feasible imputation for T, which has the minimum evolutionary cost among all feasible imputations.
The tree T, transition cost matrix ∆, and a string bv for each leaf v are given. You should write a program to compute the minimum evolutionary cost of feasible imputations.

输入

The first line of the input contains an integer n (2 ⩽ n ⩽ 10, 000) denoting the number of vertices of T. The vertices of T are numbered from 1 to n. The root of the tree is numbered 1. The root is never considered as a leaf, even if it has only one child. The next n − 1 lines describe the edges of T; each line contains two endpoints of an edge separated by spaces. 
In the next four lines, the evolutionary cost matrix ∆ is given; each line is for one row of ∆. Rows (corresponding to a parent) and columns (corresponding to a child) of ∆ are ordered to respectively represent characters A, T, C and G. All entries of ∆ are non-negative integers not more than 106 . The next line just contains k, the number of leaves. Finally,each leaf v (its number) and its bv which is a string of size m (1 ⩽ m ⩽ 200) appear in one line.

输出

In one line, print the minimum evolutionary cost of feasible imputations.

样例输入

复制样例数据

3
1 2
1 3
0 3 4 4
4 0 4 4
4 4 2 4
1 1 1 0
2
2 AAC
3 T?C

样例输出

4
#include "bits/stdc++.h"using namespace std;
typedef long long ll;
const int maxn = 1e4 + 100;
vector<int> e[maxn];
int delt[100][100];
map<char, int> mp;
char str[maxn][210];
int vis[maxn], v[maxn];
ll dp[maxn][10];void dfs(int now, int i) {v[now] = 1;if (vis[now]) {if (str[now][i] == '?') return;int k = mp[str[now][i]];for (int j = 1; j <= 4; j++) {if (j != k) dp[now][j] = 1e18;}return;}for (auto p:e[now]) {if (!v[p]) {dfs(p, i);for (int j = 1; j <= 4; j++) {ll minn = 1e18;for (int k = 1; k <= 4; k++) {minn = min(minn, dp[p][k] + delt[j][k]);}dp[now][j] += minn;}}}
}int main() {//freopen("input.txt", "r", stdin);mp['A'] = 1;mp['T'] = 2;mp['C'] = 3;mp['G'] = 4;int n;cin >> n;int x, y;for (int i = 1; i < n; i++) {cin >> x >> y;e[x].push_back(y);e[y].push_back(x);}for (int i = 1; i <= 4; i++) {for (int j = 1; j <= 4; j++) {cin >> delt[i][j];}}int k;cin >> k;for (int i = 0; i < k; i++) {cin >> x;cin >> str[x];vis[x] = 1;}ll ans = 0;int len = strlen(str[x]);for (int i = 0; i < len; i++) {memset(v, 0, sizeof(v));memset(dp, 0, sizeof(dp));dfs(1, i);ll minn = 1e18;for (int j = 1; j <= 4; j++) {minn = min(minn, dp[1][j]);}ans += minn;}cout << ans << endl;return 0;
}

转载于:https://www.cnblogs.com/albert-biu/p/10689940.html

UPC10728:Imputation相关推荐

  1. 论文笔记:FILLING THE G AP S: MULTIVARIATE TIME SERIES IMPUTATION BY GRAPH NEURAL NETWORKS

    0 abstract & introduction 之前的补全方法并不能很好地捕获/利用 不同sensor之间的非线性时间/空间依赖关系 高效的时间序列补全方法,不仅应该考虑过去(或者未来)的 ...

  2. Scikit中的特征选择,XGboost进行回归预测,模型优化的实战

    前天偶然在一个网站上看到一个数据分析的比赛(sofasofa),自己虽然学习一些关于机器学习的内容,但是并没有在比赛中实践过,于是我带着一种好奇心参加了这次比赛. 赛题:足球运动员身价估计 比赛概述 ...

  3. 探索性数据分析EDA(二)—— 缺失值处理

    接上一篇 <探索性数据分析(1)-- 变量识别和分析>, 这篇笔记主要内容为缺失值处理方法介绍,以及相关python工具包sklearn.impute的使用介绍. 目录 1. 为什么需要处 ...

  4. Kaggle课程 — 机器学习进阶 Intermediate Machine Learning

    Kaggle课程 - 机器学习进阶 Intermediate Machine Learning 1.简介 1.1 先决条件 2.缺失值 2.1 简介 2.2 三种方法 2.3 一个例子 2.3.1 定 ...

  5. 大数据技术之_19_Spark学习_07_Spark 性能调优 + 数据倾斜调优 + 运行资源调优 + 程序开发调优 + Shuffle 调优 + GC 调优 + Spark 企业应用案例

    大数据技术之_19_Spark学习_07 第1章 Spark 性能优化 1.1 调优基本原则 1.1.1 基本概念和原则 1.1.2 性能监控方式 1.1.3 调优要点 1.2 数据倾斜优化 1.2. ...

  6. golang大厂面试2

    golang大厂面试 滴滴 写个二分查找 以下是一个简单的二分查找算法的 Go 语言实现: package mainimport "fmt"// 二分查找函数 func binar ...

  7. InstallShield内部库函数

    InstallShield内部库函数 下载资源:点击 1  库函数综述 InstallShield包含300多个内部库函数,用户可在安装脚本中调用它们来创建程序组,操作文件夹,处理目录,监督安装状态, ...

  8. 论文笔记:Missing Value Imputation for Multi-view UrbanStatistical Data via Spatial Correlation Learning

    TKDE 2021(Apr) 0 摘要 作为城市化的发展趋势,海量的多视角(如人口和经济视角)的城市统计数据被越来越多地收集并受益于不同领域,包括交通服务.区域分析等. 划分为细粒度区域的数据在获取和 ...

  9. 论文笔记:NAOMI: Non-Autoregressive MultiresolutionSequence Imputation

    2019 NIPS 0 abstract 缺失值插补是时空建模中的一个基本问题,从运动跟踪到物理系统的动力学.深度自回归模型受到错误传播的影响,这对于输入远程序列来说是灾难性的.在本文中,我们采用非自 ...

最新文章

  1. 内核函数输出怎么看到_谈谈如何学习Linux内核
  2. LeetCode-剑指 Offer 58 - I. 翻转单词顺序
  3. 全志 更换Update升级路径 Patch
  4. 计算机故障检修课过时,第三场公开课|电脑故障维修以及笔记本知识科普
  5. 网络协议从入门到底层原理(7)网络安全 - 常见攻击、单向散列函数、对称加密、非对称加密、混合密码系统、数字签名、证书
  6. jquery on()动态绑定元素的的点击事件无反应的问题记录
  7. 国内移动CRM市场规模不及salesforce年营收3%
  8. 前端福利 - h5源码一键下载
  9. 拨开历史的迷雾从篡夺者战争到五王之战的政经原因
  10. unity不规则碰撞_Unity中的刚体和碰撞器
  11. 如何在计算机查找类型文件类型,怎样在电脑中查找某一类型文件?比如查 txt...
  12. BEV感知,是下一代自动驾驶感知算法风向吗?
  13. 企业安全实战】开源HIDS OSSEC部署与扩展使用
  14. YY客网络广播 内测进行中!
  15. 京东内部资料【自然搜索排序白皮书】打算混京东的屌丝必看!
  16. mipi协议csi和dsi
  17. 交换机的各种工作模式
  18. c语言的应用与作用,C语言主要应用在什么地方?
  19. oracle_day5_程序包
  20. JAVA计算机毕业设计网上购物商城(附源码、数据库)

热门文章

  1. 入门级动态规划:2018年第九届蓝桥杯省赛B组第四题—测试次数( 摔手机 )
  2. 个人晋升演讲ppt_如何写好公司级别晋升 PPT?
  3. 关键字深度剖析,集齐所有关键字可召唤神龙?【完】
  4. The Fewest Coins (混合背包)
  5. 计算机电源供电方式,电脑主板开关电源供电方式图文介绍
  6. 初学者学习JS很吃力怎么办?到底该如何学习JS?
  7. FPGA学习汇总(六)----数码管显示(1)
  8. JuliaFEM中的数据格式——fields.jl
  9. 通达信日线数据用转换为excel、csv和feather格式
  10. Shell脚本切换root用户或获取root权限