[UCSD白板题] Longest Common Subsequence of Three Sequences
Problem Introduction
In this problem, your goal is to compute the length of a longest common subsequence of three sequences.
Problem Description
Task.Given three sequences \(A=(a_1,a_2,\cdots,a_n)\); \(B = (b_1, b_2,\cdots,b_m)\), and \(C=(c_1,c_2,\cdots ,c_l)\), find the length of their longest common subsequence, i.e., the largest non-negative integer \(p\) such that there exists indices
\(1 \leq i_1 < i_2 < \cdots < i_p \leq n\),\(1 \leq j_1 < j_2 < \cdots < j_p \leq m\), \(1 \leq k_1 < k_2 < \cdots < k_p \leq l\)
such that \(a_{i_1}=b_{j_1}=c_{k_1},\cdots ,a_{i_1},b_{j_p},c_{k_p}\).
Input Format.First line: \(n\). Second line: \(a_1,a_2,\cdots,a_n\). Third line: \(m\). Fourth line: \(b_1,b_2,\cdots ,b_m\). Fifth line: \(l\). Sixth line: \(c_1,c_2,\cdots,c_l\)
Constraints.\(1 \leq n,m,l \leq 100\); \(-10^9 < a_i,b_i,c_i < 10^9\)
Output Format. Output \(p\).
Sample 1.
Input:
3
1 2 3
3
2 1 3
3
1 3 5
Output:
2
Sample 2
Input:
5
8 3 2 1 7
7
8 2 1 3 8 10 7
6
6 8 3 1 4 7
Output:
3
Solution
[UCSD白板题] Longest Common Subsequence of Three Sequences的更多相关文章
- [UCSD白板题] Least Common Multiple
Problem Introduction The least common multiple of two positive integers \(a\) and \(b\) is the least ...
- [UCSD白板题] Greatest Common Divisor
Problem Introduction The greatest common divisor \(GCD(a, b)\) of two non-negative integers \(a\) an ...
- UVA 10405 Longest Common Subsequence (dp + LCS)
Problem C: Longest Common Subsequence Sequence 1: Sequence 2: Given two sequences of characters, pri ...
- 2017-5-14 湘潭市赛 Longest Common Subsequence 想法题
Longest Common Subsequence Accepted : Submit : Time Limit : MS Memory Limit : KB Longest Common Subs ...
- 动态规划求最长公共子序列(Longest Common Subsequence, LCS)
1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...
- LintCode Longest Common Subsequence
原题链接在这里:http://www.lintcode.com/en/problem/longest-common-subsequence/ 题目: Given two strings, find t ...
- Lintcode:Longest Common Subsequence 解题报告
Longest Common Subsequence 原题链接:http://lintcode.com/zh-cn/problem/longest-common-subsequence/ Given ...
- LeetCode 1143. Longest Common Subsequence
原题链接在这里:https://leetcode.com/problems/longest-common-subsequence/ 题目: Given two strings text1 and te ...
- LCS(Longest Common Subsequence 最长公共子序列)
最长公共子序列 英文缩写为LCS(Longest Common Subsequence).其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已 ...
随机推荐
- alhpa阶段回顾
说明:本次课程,大家按照我下面列出来的问题进行回顾和反思,总结alhpa阶段以来的得失.每个组都要回答这些问题.由组长或者组员来回答都可以.目的依然是让大家养成软工的一些习惯和思维方式. 1.最初的需 ...
- IntelliJ设置鼠标悬浮提示和修改快捷键
IntelliJ设置鼠标悬浮提示和修改快捷键 设置鼠标悬浮提示 修改快捷键 进入设置菜单 删除原来的快捷键(注:你可以选择保留原来的快捷键,同时使用两个快捷键) Good Luck
- Ubuntu:我不小心把/var/lock文件夹给删了
在一个风和日丽的下午,不正常关闭minicom导致了device 没有正常解锁,于是使用minicom的时候提示 device is locked: 根据网上看到的方法只要把/var/lock 里面的 ...
- 显示天气预报的Demo
实现的效果如下所示: 代码如下: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewCo ...
- iOS 键盘类型
版权声明:本文为博主原创文章.请尊重作者劳动成果,转载请注明出处. UIKeyboardTypeDefault: UIKeyboardTypeASCIICapable: UIKeyboardTypeN ...
- 错误的CPU时间片大小概念
1.错误的CPU时间片大小概念:http://blog.csdn.net/blue_morning/article/details/7843581 2.时间片:http://baike.baidu.c ...
- [转] Android 4.4中播放HTML5视频<video>的Bug
近期Nexus 4手机自动升级到Android4.4,本来挺好的一件事儿,结果发现自己的应用中出现一个Bug,应用中使用了Webview播放HTML5视频,代码如下: <video width= ...
- ios UILabel在storyBoard或xib中如何在每行文字不显示完就换行
大家知道怎么用代码让label中的文字换行,只需要 label.numberOfLines = 0; label.text = @"这是第一行啦啦啦啦,\n这是第二行啦啦,\n这是第三行&q ...
- Bootstrap Table Examples
The examples of bootstrap table http://bootstrap-table.wenzhixin.net.cn/examples/ http://www.jq22.co ...
- 【随笔】js加载
有时候,当发现js操作一个dom的时候,发现dom没有找到,这是由于html没有加载完就开始操作该dom的缘故,所以需要在html文档加载完后再加载js,于是我们可以这么做: js方法:window. ...