Codeforces 747B Mammoth's Genome Decoding(碱基对)

来源:互联网 发布:淘宝盗图技巧不被发现 编辑:程序博客网 时间:2024/06/08 05:52

http://codeforces.com/contest/747/problem/B
B. Mammoth's Genome Decoding
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The process of mammoth's genome decoding in Berland comes to its end!

One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a question mark '?'. Thus, s is a string consisting of letters 'A', 'C', 'G', 'T' and characters '?'.

It is known that the number of nucleotides of each of the four types in the decoded genome of mammoth in Berland should be equal.

Your task is to decode the genome and replace each unrecognized nucleotide with one of the four types so that the number of nucleotides of each of the four types becomes equal.

Input

The first line contains the integer n (4 ≤ n ≤ 255) — the length of the genome.

The second line contains the string s of length n — the coded genome. It consists of characters 'A', 'C', 'G', 'T' and '?'.

Output

If it is possible to decode the genome, print it. If there are multiple answer, print any of them. If it is not possible, print three equals signs in a row: "===" (without quotes).

Examples
input
8AG?C??CT
output
AGACGTCT
input
4AGCT
output
AGCT
input
6????G?
output
===
input
4AA??
output
===
Note

In the first example you can replace the first question mark with the letter 'A', the second question mark with the letter 'G', the third question mark with the letter 'T', then each nucleotide in the genome would be presented twice.

In the second example the genome is already decoded correctly and each nucleotide is exactly once in it.

In the third and the fourth examples it is impossible to decode the genom.



题意:

给定长度为 n 的只含有 A T C G ? 的字符串,其中的 ? 可以转换为任何一个字母,问是否存在 A T C G碱基个数需要相等。

不存在输出 ===

思路:

简单的模拟题,尴尬的就在于,明明在提交输出的多一个 ->  ?  


AC CODE:

#include<stdio.h>#include<cstring>#include<cmath>#include<algorithm>#define HardBoy main()#define ForMyLove return 0;using namespace std;const int MYDD = 1103;int HardBoy {int a = 0, g = 0, c = 0, t = 0, n; char s[MYDD];scanf("%d %s", &n, s);if(n%4 != 0){puts("===");} else {for(int j = 0; j < n; j++){if(s[j] == '?') continue;if(s[j] == 'A') a++;else if(s[j] == 'C') c++;else if(s[j] == 'G') g++;else if(s[j] == 'T') t++;} int v = n/4;if(c > v || a > v || g > v || t > v){puts("===");} else {for(int j = 0; j < n; j++){if(s[j] == '?'){if(a < v){s[j] = 'A';a++;} else if(c < v){s[j] = 'C';c++;} else if(g < v){s[j] = 'G';g++;} else if(t < v){s[j] = 'T';t++;}}}printf("%s\n", s);} }ForMyLove} 


所谓 WA CODE:

#include<stdio.h>#include<cstring>#include<cmath>#include<algorithm>#define HardBoy main()#define ForMyLove return 0;using namespace std;const int MYDD = 1103;int HardBoy {int a[4] ={0}, b[4] ={0}, n;char s[MYDD], zi[] = {"ACGT"};scanf("%d %s", &n, s); if(n % 4){puts("===");} else {for(int j = 0; j < n; j ++){if(s[j] == 'A') a[0]++;if(s[j] == 'C') a[1]++;if(s[j] == 'G') a[2]++;if(s[j] == 'T') a[3]++;}for(int j = 0; j < 4; j++){b[j] = n/4 - a[j];if(b[j] < 0){puts("===");return 0;}}for(int i = 0; i < n; i++){while(s[i] == '?'){for(int j = 0; j < 4; j++){if(b[j] <= 0) continue; printf("%c", zi[j]);b[j]--;i++;break;}}  printf("%c", s[i]);  }}ForMyLove}/*8????????ACCATTGG*/



0 0
原创粉丝点击