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(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.
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
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
水题,直接模拟。
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|1
using 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;
}