hdoj 5590 ZYB's Biology 【水题】

来源:互联网 发布:sql server 2008下载 编辑:程序博客网 时间:2024/06/05 07:02

ZYB's Biology

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


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
24ACGTUGCA4ACGTACGU
 

Sample Output
YESNO
 



水题,直接模拟。


AC代码:


#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <set>#include <vector>#define INF 0x3f3f3f#define eps 1e-8#define MAXN (100+10)#define MAXM (100000)#define Ri(a) scanf("%d", &a)#define Rl(a) scanf("%lld", &a)#define Rf(a) scanf("%lf", &a)#define Rs(a) scanf("%s", a)#define Pi(a) printf("%d\n", (a))#define Pf(a) printf("%.2lf\n", (a))#define Pl(a) printf("%lld\n", (a))#define Ps(a) printf("%s\n", (a))#define W(a) while(a--)#define CLR(a, b) memset(a, (b), sizeof(a))#define MOD 1000000007#define LL long long#define lson o<<1, l, mid#define rson o<<1|1, mid+1, r#define ll o<<1#define rr o<<1|1using namespace std;bool judge(char a, char b){    if(a == 'A' && b == 'U') return true;    if(a == 'T' && b == 'A') return true;    if(a == 'C' && b == 'G') return true;    if(a == 'G' && b == 'C') return true;    return false;}int main(){    int t; Ri(t);    W(t)    {        int n;        char a[110], b[110];        Ri(n);        Rs(a); Rs(b);        bool flag = true;        for(int i = 0; i < n; i++)        {            if(!judge(a[i], b[i]))            {                flag = false;                break;            }        }        printf(flag ? "YES\n" : "NO\n");    }    return 0;}


0 0
原创粉丝点击