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的更多相关文章

  1. [UCSD白板题] Least Common Multiple

    Problem Introduction The least common multiple of two positive integers \(a\) and \(b\) is the least ...

  2. [UCSD白板题] Greatest Common Divisor

    Problem Introduction The greatest common divisor \(GCD(a, b)\) of two non-negative integers \(a\) an ...

  3. UVA 10405 Longest Common Subsequence (dp + LCS)

    Problem C: Longest Common Subsequence Sequence 1: Sequence 2: Given two sequences of characters, pri ...

  4. 2017-5-14 湘潭市赛 Longest Common Subsequence 想法题

    Longest Common Subsequence Accepted : Submit : Time Limit : MS Memory Limit : KB Longest Common Subs ...

  5. 动态规划求最长公共子序列(Longest Common Subsequence, LCS)

    1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...

  6. LintCode Longest Common Subsequence

    原题链接在这里:http://www.lintcode.com/en/problem/longest-common-subsequence/ 题目: Given two strings, find t ...

  7. Lintcode:Longest Common Subsequence 解题报告

    Longest Common Subsequence 原题链接:http://lintcode.com/zh-cn/problem/longest-common-subsequence/ Given ...

  8. LeetCode 1143. Longest Common Subsequence

    原题链接在这里:https://leetcode.com/problems/longest-common-subsequence/ 题目: Given two strings text1 and te ...

  9. LCS(Longest Common Subsequence 最长公共子序列)

    最长公共子序列 英文缩写为LCS(Longest Common Subsequence).其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已 ...

随机推荐

  1. [原创.数据可视化系列之三]使用Ol3加载大量点数据

    不管是百度地图还是高德地图,都很难得见到在地图上加载大量点要素,比如同屏1000的,因为这样客户端性能会很低,尤其是IE系列的浏览器,简直是卡的要死.但有的时候,还真的需要,比如,我要加载全球的AQI ...

  2. 调用别人提供的WebService

    在开发过程中,许多时候需要使用到别人提供的WebService接口,使用其中的方法. 在调用别人提供的接口时,会得到接口使用的文档,其中包括接口的网络地址及方法作用等. 找到WebService的ws ...

  3. h5 摄像头处理 在线视频

    http://www.360doc.com/content/08/0812/03/72059_1533104.shtml http://html5online.com.cn/articles/2012 ...

  4. 同时打开两个excel工作窗口

    先打开你想要同时打开的两个excel文件,有两个方法可以同时打开两个窗口:首先选取任意一个文件,1. 点击“窗口”菜单==>"重排窗口"==>选择你想同时打开的样式== ...

  5. Finders Keepers

    function find(arr, func) { //var num = 0; //return num; var res = arr.filter(func); if(res.length){ ...

  6. markdown基本操作

    #                                    一级标题 ##                                  二级标题,以此类推 - 或者 *       ...

  7. 解决libcurl7.50.3在windows XP SP3 VC++ 6.0下编译报错 unresolved external symbol __imp__IdnToAscii@20 unresolved external symbol __imp__IdnToUnicode@20

    错误重现: --------------------Configuration: curl - Win32 LIB Debug DLL Windows SSPI DLL WinIDN--------- ...

  8. C++中虚继承派生类构造函数的正确写法

    最近工作中某个软件功能出现了退化,追查下来发现是一个类的成员变量没有被正确的初始化.这个问题与C++存在虚继承的情况下派生类构造函数的写法有关.在此说明一下错误发生的原因,希望对更多的人有帮助. 我们 ...

  9. django TEMPLATES

    ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dic ...

  10. XE3随想14:关于 SO 与 SA 函数

    通过 SuperObject 的公用函数 SO 实现一个 ISuperObject 接口非常方便; 前面都是给它一个字符串参数, 它的参数可以是任一类型甚至是常数数组. SA 和 SO 都是返回一 I ...