第十一屆河南ACM Gene mutation(模擬)
提交地址:點選開啟連結
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 eye’s 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 eye’s 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
樣例輸入
161 8 5 7 9 1034 6 7
樣例輸出
2
排序,再掃一遍陣列就行了
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n1,n2,cnt=0;
int a[20010],b[106],c[106];
cin>>n1;
for(int i = 0;i<n1;i++)
cin>>a[i];
cin>>n2;
for(int i = 0;i<n2;i++)
cin>>b[i];
sort(b,b+n2);
int tmp = b[0];
for(int i = 0;i< n2;i++)
b[i] = b[i]-tmp;
// for(int i = 0;i< n2;i++)
// cout<<b[i]<<" ";
// cout<<'\n';
for(int i = 0;i<n1-n2+1;i++)
{
for(int j = 0,k=i;j<n2;j++)
{
c[j] = a[k++];
}
sort(c,c+n2);
tmp = c[0];
int flag = true;
for(int j =0;j<n2;j++)
{
c[j] = c[j]- tmp; // cout<<c[j]<<' ';
if(c[j]!=b[j]) {
flag = false;
}
}
if(flag) cnt++;
}
cout<<cnt<<endl;
}
return 0;
}
/*
1
6
1 8 5 7 9 10
3
4 6 7
*/
相關文章
- 【藍橋杯考前突擊】第十一屆藍橋杯校賽模擬C/C++ 正整數序列C++
- 第十一屆藍橋杯大賽第二次模擬(軟體類)真題(做題筆記)筆記
- 2024屆新題型數學模擬選題
- 湖南大學2020屆ACM新生賽 部分題解ACM
- 模擬比賽-14屆研究生組C++省賽C++
- 昆工25屆817訊號與系統模擬考試
- Mutation Observer優點Server
- 第十四屆藍橋杯第一期模擬賽 pythonPython
- 裝飾器設計模式 - Gene Zeiniss設計模式
- 模擬
- ACM-ICPC 2018 南京賽區網路預賽 __G Lpl and Energy-saving Lamps【線段樹+模擬】ACMLAMP
- 10.6 模擬賽(NOIP 模擬賽 #9)
- 2024.11.20 NOIP模擬 - 模擬賽記錄
- 有限元模擬 有限體積模擬
- git 模擬Git
- ACP模擬
- 模擬題
- 模擬賽
- 第二十屆西南科技大學ACM程式設計競賽(同步賽)ACM程式設計
- Mutation Observer儲存原有的值Server
- [Vuex系列] - Mutation的具體用法Vue
- vuex 原始碼:深入 vuex 之 mutationVue原始碼
- Altair SimSolid 工程模擬軟體 衡祖模擬AISolid
- Gpssworld模擬(二):並排排隊系統模擬
- 河南萌新聯賽2024第(三)場:河南大學
- 第十一屆藍橋杯省賽CC++組第二場比賽C++
- 「模擬賽」暑期集訓CSP提高模擬15(8.7)
- 「模擬賽」暑期集訓CSP提高模擬3(7.20)
- 「模擬賽」暑期集訓CSP提高模擬5(7.22)
- 「模擬賽」暑期集訓CSP提高模擬6(7.23)
- 「模擬賽」暑期集訓CSP提高模擬10(7.28)
- ACM summaryACM
- ACM notesACM
- Vuex中使用報錯unknown mutation typeVue
- 5.4 模擬賽
- 2024.2.18 模擬賽
- 2024.1.26 模擬賽
- 2024.1.23 模擬賽