Problem Description
After getting 600 scores in NOIP ZYB(ZJ−267) begins to work with biological questions.Now he give you a simple biological questions: he gives you a DNA sequence and a RNA sequence,then he asks you whether the DNA sequence and the RNA sequence are matched. The DNA sequence is a string consisted of A,C,G,T;The RNA sequence is a string consisted of A,C,G,U. DNA sequence and RNA sequence are matched if and only if A matches U,T matches A,C matches G,G matches C on each position.
Input
In the first line there is the testcase T. For each teatcase: In the first line there is one number N. In the next line there is a string of length N,describe the DNA sequence. In the third line there is a string of length N,describe the RNA sequence. 1≤T≤10,1≤N≤100
Output
For each testcase,print YES or NO,describe whether the two arrays are matched.
Sample Input
2 4 ACGT UGCA 4 ACGT ACGU
Sample Output
YES NO
Source
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include<iostream> 3 #include<cstdio> 4 #include<cstring> 5 #include<cmath> 6 #include<math.h> 7 #include<algorithm> 8 #include<queue> 9 #include<set> 10 #include<bitset> 11 #include<map> 12 #include<vector> 13 #include<stdlib.h> 14 #include <stack> 15 using namespace std; 16 #define PI acos(-1.0) 17 #define max(a,b) (a) > (b) ? (a) : (b) 18 #define min(a,b) (a) < (b) ? (a) : (b) 19 #define ll long long 20 #define eps 1e-10 21 #define MOD 1000000007 22 #define N 106 23 #define inf 1e12 24 int n; 25 char s1[N]; 26 char s2[N]; 27 int main() 28 { 29 int t; 30 scanf("%d",&t); 31 while(t--){ 32 scanf("%d",&n); 33 scanf("%s",s1); 34 scanf("%s",s2); 35 int flag=1; 36 for(int i=0;i<n;i++){ 37 if(s1[i]==‘A‘){ 38 if(s2[i]!=‘U‘){ 39 flag=0; 40 break; 41 } 42 } 43 else if(s1[i]==‘T‘){ 44 if(s2[i]!=‘A‘){ 45 flag=0; 46 break; 47 } 48 } 49 else if(s1[i]==‘C‘){ 50 if(s2[i]!=‘G‘){ 51 flag=0; 52 break; 53 } 54 } 55 else if(s1[i]==‘G‘){ 56 if(s2[i]!=‘C‘){ 57 flag=0; 58 break; 59 } 60 } 61 } 62 if(flag){ 63 printf("YES\n"); 64 }else{ 65 printf("NO\n"); 66 } 67 68 69 } 70 return 0; 71 }
hdu 5590 ZYB's Biology
时间: 2024-10-13 09:33:01