HDOJ 5590 ZYB's Biology

ZYB's Biology

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 330    Accepted Submission(s): 275


Problem Description
After getting 600 scores in NOIP ZYB(ZJ267) 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.

1T10 , 1N100
 

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
 

ac代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 60001
#define LL long long
#define INF 0xfffffff
#define fab(x) (x)>0?(x):(-x)
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
using namespace std;
char s1[MAXN],s2[MAXN];
int main()
{
	int i,n,t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		scanf("%s%s",s1,s2);
		int bz=0;
		for(i=0;i<n;i++)
		{
			if((s1[i]=='A'&&s2[i]!='U')||(s1[i]=='C'&&s2[i]!='G')||(s1[i]=='G'&&s2[i]!='C')||(s1[i]=='T'&&s2[i]!='A'))
			{
				bz=1;
				break;
			}
		}
		printf(bz?"NO\n":"YES\n");
	}
	return 0;
}


你可能感兴趣的:(HDOJ 5590 ZYB's Biology)