-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path747B Mammoth_s Genome Decoding.cpp
76 lines (68 loc) · 1.49 KB
/
747B Mammoth_s Genome Decoding.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
author : MishkatIT
created : Thursday 2022-10-27-20.42.29
problem : 747 B. Mammoth's Genome Decoding
*/
#include<iostream>
#include<string>
#include<algorithm>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
fio;
bool ok = true;
int n;
string str;
cin >> n >> str;
if(n%4 != 0)
{
ok = false;
goto en;
}
else
{
int A = n/4;
int C = n/4;
int G = n/4;
int T = n/4;
for(int i=0; i<str.length(); i++)
if(str[i] == 'A')
A--;
else if(str[i] == 'C')
C--;
else if(str[i] == 'G')
G--;
else if(str[i] == 'T')
T--;
for(int i=0; i<str.length(); i++)
if(str[i] == '?')
{
if( A > 0)
{
str[i] = 'A';
A--;
}
else if( C > 0)
{
str[i] = 'C';
C--;
}
else if( G > 0)
{
str[i] = 'G';
G--;
}
else if( T > 0)
{
str[i] = 'T';
T--;
}
}
if(A > 0 or C > 0 or G > 0 or T > 0)
ok = false;
}
en:
cout << (ok ? str : "===");
return 0;
}