Codeforces Mammoth's Genome Decoding
/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;
const int mod = 1000007;
const int high = 300;
//struct my
//{
// char ch;
// int wieght;
//}ar[high];
int main()
{
fast;
int n , len , i , j;
char ch[]={'A' , 'C' , 'G' , 'T'};
string s , ans;
mpci mp;
while(cin >> n)
{
mp.clear();
cin >> s;
ans=s;
len = s.length();
if(len % 4 != 0)
{
cout << "===\n";
}
else
{
int maxi = 0, slen=0;
for(i=0; i<len; i++)
{
if(s[i] != '?')
{
mp[s[i]]++;
maxi = max(mp[s[i]] , maxi);
}
}
if(maxi * 4 <= len)
{
int q = len / 4;
mp['A'] = abs(q - mp['A']);
mp['C'] = abs(q - mp['C']);
mp['G'] = abs(q - mp['G']);
mp['T'] = abs(q - mp['T']);
for(i=0; i<len; i++)
{
if(s[i] == '?')
{
for(j=0; j<4; j++)
{
if(mp[ch[j]])
{
ans[i] = ch[j];
mp[ch[j]]--;
break;
}
}
}
}
outn(ans);
}
else
{
cout << "===\n";
}
}
}
return 0;
}
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;
const int mod = 1000007;
const int high = 300;
//struct my
//{
// char ch;
// int wieght;
//}ar[high];
int main()
{
fast;
int n , len , i , j;
char ch[]={'A' , 'C' , 'G' , 'T'};
string s , ans;
mpci mp;
while(cin >> n)
{
mp.clear();
cin >> s;
ans=s;
len = s.length();
if(len % 4 != 0)
{
cout << "===\n";
}
else
{
int maxi = 0, slen=0;
for(i=0; i<len; i++)
{
if(s[i] != '?')
{
mp[s[i]]++;
maxi = max(mp[s[i]] , maxi);
}
}
if(maxi * 4 <= len)
{
int q = len / 4;
mp['A'] = abs(q - mp['A']);
mp['C'] = abs(q - mp['C']);
mp['G'] = abs(q - mp['G']);
mp['T'] = abs(q - mp['T']);
for(i=0; i<len; i++)
{
if(s[i] == '?')
{
for(j=0; j<4; j++)
{
if(mp[ch[j]])
{
ans[i] = ch[j];
mp[ch[j]]--;
break;
}
}
}
}
outn(ans);
}
else
{
cout << "===\n";
}
}
}
return 0;
}
Comments
Post a Comment