time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard 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

8

AG?C??CT

output

AGACGTCT

input

4

AGCT

output

AGCT

input

6

????G?

output

input

4

AA??

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.

【题目链接】:http://codeforces.com/contest/747/problem/B

【题解】



最后每种碱基肯定都是n/4;

当然如果一开始就大于n/4要输出无解.

如果n不能被4整除;也直接输出无解。

然后枚举每一个问号要换成什么碱基就好;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const char temp[5] = {'0','A','T','C','G'};
const double pi = acos(-1.0); int n,q =0,a[5];
string s; int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> n;
cin >> s;
rep1(i,0,n-1)
if (s[i]=='?')
q++;
else
if (s[i] == 'A')
a[1]++;
else
if (s[i] == 'T')
a[2]++;
else
if (s[i] == 'C')
a[3] ++;
else
if (s[i] =='G')
a[4]++;
if ((n%4)!=0)
{
puts("===");
return 0;
}
n/=4;
rep1(i,1,4)
if (a[i]>n)
{
puts("===");
return 0;
}
int len = s.size();
rep1(i,0,len-1)
if (s[i]=='?')
{
bool fi = false;
rep1(j,1,4)
if (a[j]<n)
{
a[j]++;
s[i] = temp[j];
fi = true;
break;
}
if (!fi)
{
puts("===");
return 0;
}
q--;
}
cout << s<<endl;
return 0;
}

【58.33%】【codeforces 747B】Mammoth's Genome Decoding的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【23.33%】【codeforces 557B】Pasha and Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【33.10%】【codeforces 604C】Alternative Thinking

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【25.33%】【codeforces 552D】Vanya and Triangles

    time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  5. 【33.33%】【codeforces 552B】Vanya and Books

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【33.33%】【codeforces 586D】Phillip and Trains

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【33.33%】【codeforces 608C】Chain Reaction

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【21.58%】【codeforces 746D】Green and Black Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【codeforces 807D】Dynamic Problem Scoring

    [题目链接]:http://codeforces.com/contest/807/problem/D [题意] 给出n个人的比赛信息; 5道题 每道题,或是没被解决->用-1表示; 或者给出解题 ...

随机推荐

  1. 什么是PV UV

    PV是网站分析的一个术语,用以衡量网站用户访问的网页的数量.对于广告主,PV值可预期它可以带来多少广告收入.一般来说,PV与来访者的数量成正比,但是PV并不直接决定页面的真实来访者数量,如同一个来访者 ...

  2. fedora 安装ftp

    fedora默认不安装ftp服务(包括client程序/service程序),需要进行手动安装: yum install ftp(安装client) yum install vsftpd(安装serv ...

  3. nodeJs学习-15 mysql中间件下载与使用、基本用法

    下载mysql中间件(客户端):cnpm install mysql 链接数据库.查询示例: const mysql=require('mysql'); //1.连接 //createConnecti ...

  4. 介绍配置管理工具SVN的使用

    配置管理CM(Configuration Mangerment) 一.配置管理工具SVN的介绍 ---Subversion ---是一个开放源代码的版本控制系统 ---时下流行的SVN和GIT 每天开 ...

  5. hdu2018 dp

    /* 1~4直接取得: 然后后面的生牛的时候都是前一年的加上一定的数. 从第5年看,第五年出生的牛肯定要加上第四年出生的,然后由于第一个出生的牛开始生小牛,这和 最开始的牛生孩子是一样的,所以+dp[ ...

  6. 笔记:less的三种使用方法

    直接在浏览器端使用 第一步,引入 .less 文件(注意要将 rel 属性设置为“stylesheet/less”) <link rel="stylesheet/less" ...

  7. python 终端编码

  8. Java练习 SDUT-1132_斐波那契数列

    C/C++经典程序训练2---斐波那契数列 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 编写计算斐波那契(Fibon ...

  9. 9 模版语言 jinja2

    from flask import Flask,redirect,render_template,jsonify,send_file,request,Markup,sessionimport json ...

  10. 关于python 中的__future__模块

    Python的每个新版本都会增加一些新的功能,或者对原来的功能作一些改动.有些改动是不兼容旧版本的,也就是在当前版本运行正常的代码,到下一个版本运行就可能不正常了. 具体说来就是,某个版本中出现了某个 ...