第十一届河南省赛 Gene mutation(模拟)

本文介绍了一种算法,用于解决基因序列匹配的问题。该算法通过对比两组数字序列,判断第一组序列中有多少个子序列可以通过加减操作及排序转换为第二组序列。此问题的应用背景涉及生物学中对基因序列的研究。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                                    2110 : Gene mutation

时间限制:3 Sec 内存限制:256 MiB

提交 状态 讨论区

题目描述


 

Gene mutation is the sudden and inheritable mutation of genomic DNA molecules. From the molecular level, gene mutation refers to the change of the composition or sequence of base pairs in the structure of a gene. Although the gene is very stable, it can reproduce itself accurately when the cell divides. Under certain conditions, the gene can also suddenly change from its original existence to another new form of existence.

 

A genome sequence might provide answers to major questions about the biology and evolutionary history of an organism.  A 2010 study found  a gene sequence in the skin of cuttlefish  similar to those in the eyes retina. If the gene matches, it can be used to treat certain diseases of the eye.

 

A gene sequence in the skin of cuttlefish  is specified by a sequence of distinct integers (Y1,Y2, …Yc). it  may be mutated. Even if these integers are transposed  ( increased or decreased by a common amount ) ,  or re-ordered ,  it is still a gene sequence of cuttlefish.  For example,  if  "4 6 7"  is a gene sequence of cuttlefish, then "3 5 6" (-1), "6 8 9" ( +2),  "6 4 7" (re-ordered), and "5 3 6" (transposed and re-ordered) are also ruminant a gene sequence of cuttlefish.

 

Your task is to determine that there are several matching points at most  in a gene sequence of the eyes retina (X1,X2, , Xn)

输入


 

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=5).  Each test case specifies:

* Line 1:       n                   ( 1 ≤ n ≤ 20,000 )

* Line 2:       X1  X2… Xn        ( 1 ≤ Xi ≤ 100    i=1…. n)

* Line 3:       c                   ( 1 ≤ c≤ 10 )

* Line 4:       Y1  Y2… Yc        ( 1 ≤ Yi ≤ 100    i=1…. c)

输出


 

For each test case generate a single line:  a single integer that there are several matching points. The matching gene sequence can be partially overlapped

样例输入

复制
1 
6 
1 8 5 7 9 10
3
4 6 7

样例输出

复制
2

题意:给了两组数,然后问第一组数中有多少个子数组,加减任意数再任意排序可以得到第二组数。

思路:先对b数组进行排序,然后在a数组取出和b数组相同的数处理后再排序,看是否符合条件。

ACDAIMA:

#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n, c, cnt = 0, a[20005], b[15], s[20005];
        scanf("%d",&n);
        for(int i = 0; i < n; i++) scanf("%d",&a[i]);
        scanf("%d",&c);
        for(int i = 0; i < c; i++) scanf("%d",&b[i]);
        sort(b,b+c);
        for(int i = 0; i < n-c+1; i++)
        {
            int flag = 0;
            for(int j = 0, k = i; j < c; j++) s[j] = a[k++];
            sort(s,s+c);
            int ans = s[0] - b[0];
            for(int j = 0; j < c; j++)
            {
               if(b[j] + ans != s[j])
                    flag = 1;
            }
            if(flag == 0)
                cnt++;
        }
        printf("%d\n",cnt);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值