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. 顶点着色器详解 (Vertex Shaders)

    学习了顶点处理,你就知道固定功能流水线怎么将顶点从模型空间坐标系统转化到屏幕空间坐标系统.虽然固定功能流水线也可以通过设置渲染状态和参数来改变最终输出的结果,但是它的整体功能还是受限.当我们想实现一个 ...

  2. User mode and kernel mode

    [User mode and kernel mode] 参考:https://msdn.microsoft.com/en-us/library/windows/hardware/ff554836(v= ...

  3. 分享一个web存储方法

    https://github.com/zhujiasheng/jquery-cookie/blob/master/src/jquery.cookie.js https://github.com/WQT ...

  4. Linux Svn 安装过程及配置

    重要的是第一步的安装,第二步配置可能没用,但是没试过,因为服务器上已经安装了第一步. 此处的第二步只为做个记录,说明一下里边的配置文件的用途. 3. 自己实际操作中的的配置记录(参照服务器别人的配置记 ...

  5. 手把手教你用新浪云容器 Java 搭建自己的网站

    经过一段时间的开发,更新,迭代,新浪云容器 Java 环境逐渐成熟起来,相比过去的 Java 运行环境,可用性和易用性都得到了大量的提升.同时也收到了不少用户反馈的使用问题,特此在这篇文章里综合介绍一 ...

  6. WIN7环境下CUDA7.5的安装、配置和测试(Visual Studio 2010)

    以下基于"WIN7(64位)+Visual Studio 2010+CUDA7.5". 系统:WIN7,64位 开发平台:Visual Studio 2010 显卡:NVIDIA ...

  7. Fedora 21 64位系统安装WPS教程

    WPS的Linux版本的出现简直是Linux党的福音,Ubuntu上的WPS安装非常简单,但是在Fedora上却有点小麻烦.主要是库的依赖问题.下面记录一下Fedora 21的64位版安装WPS的完整 ...

  8. JS编写背景图切换

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  9. UIWebView、WKWebView使用详解及性能分析

    http://www.cnblogs.com/junhuawang/p/5759224.html

  10. 用.net访问电子枢纽信用中心的数据查询服务

    概要说明 电子枢纽全称国家交通运输物流公共信息平台,主要提供物流及生产企业进行物流相关数据交换的标准和API,详细介绍可参考其官网www.logink.org,本文假定阅读者对该平台已有了解,并已成功 ...