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;
}

最新文章

  1. 【转】GitHub 排名前 100 的安卓、iOS项目简介
  2. Your awesome titleHH
  3. javax.servlet.jsp.JspException cannot be resolved to a type
  4. Leetcode#61 Rotate List
  5. 使用node.js抓取有路网图书信息(原创)
  6. Android studio教程:[5]活动的生命周期
  7. HDU1217:Arbitrage(SPFA)
  8. CMake必知必会
  9. 用ASP.NET Core 2.0 建立规范的 REST API
  10. bzoj 3551 kruskal重构树dfs序上的主席树
  11. OpenStack-Nova(4)
  12. Java当中的IO一
  13. 《视觉SLAM十四讲课后作业》第二讲
  14. pymysql 数据库操控
  15. Java IO中转换流的作用
  16. PHP-引入文件(include)后,页面错位,不居中解决办法
  17. ubuntu16.04安装ssh服务,并实现远程访问
  18. 洛谷P4774 BZOJ5418 LOJ2721 [NOI2018]屠龙勇士(扩展中国剩余定理)
  19. iOS开发-类簇(Class Cluster)
  20. 【Unity】4.5 树木创建器

热门文章

  1. oracle一些常见的问题
  2. BZOJ 1834网络扩容题解
  3. 16.libgdx根据配置文件生成布局(未完)
  4. AbstractExecutorService的submit方法概要介绍
  5. 复杂SQL示例 (排行榜需求)
  6. cPickle对python对象进行序列化,序列化到文件或内存
  7. LeetCode74 Search a 2D Matrix
  8. SDUT-2122_数据结构实验之链表七:单链表中重复元素的删除
  9. Notepad++颜色配置
  10. @bzoj - 3749@ [POI2015] Łasuchy