Bzoj 1264 Gene match match (LCS conversion lis)

Source: Internet
Author: User

Title Link: http://61.187.179.132/JudgeOnline/problem.php?id=1264

Test instructions: Give two series, each of the length of the series is 5n, wherein 1-n each number appears 5 times. The longest common child of two columns.

Idea: LCS turned into LIS, for each number that appears in the first array, turn it into the position in the second array, notice that the position is from the big to the small row, and then do the LIS for this array.

#include <algorithm>#include<cstdio>#include<cmath>#include<cstring>#include<iostream>intq[1000005],a[1000005],b[1000005],n,p[1000005],s[100005][6];intFindintx) {    intL=1, r=q[0],ans; if(x<=q[1])return 0;  while(l<=R) {        intMid= (L+R)/2; if(q[mid]<x) ans=mid,l=mid+1; Elser=mid-1; }    if(q[ans+1]&LT;X)returnans+1; returnans;}intMain () {scanf ("%d",&N);  for(intI=1; i<=5*n;i++) scanf ("%d",&A[i]);  for(intj=1; j<=5*n;j++) scanf ("%d",&B[j]);  for(intI=1; i<=5*n;i++){         for(intj=1; j<=5; j + +)         if(s[b[i]][j]==0) {S[b[i]][j]=i;  Break; }    }     for(intI=1; i<=5*n;i++){        intt=A[i];  for(intj=5; j>=1; j--) p[++p[0]]=S[t][j]; } q[0]=1; q[1]=p[1];  for(intI=2; i<=p[0];i++){        if(p[i]>q[q[0]]) q[++q[0]]=P[i]; Else{            intt=find (P[i]); Q[t+1]=P[i]; }} printf ("%d\n", q[0]); }

Bzoj 1264 Gene match match (LCS conversion lis)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.