In this

**HackerEarth Special numbers problem solution,**you are creating a vaccine to fight against a worldwide novel pandemic virus. A vaccine contains a weakened virus that is injected inside people to produce antibodies to let it fight against the virus. The study of interaction among RNA of various viruses is quite necessary for this. An RNA consists of four types of molecules Guanine (G), Adenine (A), Cytosine (C), and Uracil (U).You are given the structures of RNA for the pandemic virus and several vaccine viruses in the form of strings containing characters G, A, C, and U representing respective molecules. You know that if there is higher interaction between the pandemic virus and vaccine virus, then better the vaccine will be. You also know that the only interaction between any two RNAs is a result of the interaction between their Guanine (G) and Cytosine (C) molecules. Formally, if the strings for RNA structures are s1 and s2, then you must consider the following points:

One molecule of Guanine (G) of s1 and one molecule of Cytosine (C) of s2 will lead to one unit of interaction.

One molecule of Guanine (G) of s2 and one molecule of Cytosine (C) of s1 will lead to one unit of interaction.

Any other pair of molecules do not add to any interactions.

In this way, the total interaction between s1 and s2 is calculated as the sum of individual molecule pair interactions (as discussed above).

You must find the best available vaccine.

## HackerEarth Finding vaccines problem solution.

```
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t;
// cin>>t;
t=1;
while(t--)
{
ll n,i,j,g1=0,c1=0,g2=0,c2=0,maxx=0,ans=1,rs,ss;
cin>>n;
assert(1<=n&&n<=1000);
string r,s;
cin>>rs;
cin>>r;
assert(1<=rs&&rs<=1000);
for(i=0;i<rs;++i)if(r[i]=='G')g1++;else if(r[i]=='C')c1++;
ll a[n];
for(i=0;i<n;++i)
{
cin>>ss;
cin>>s;
assert(1<=ss&&ss<=1000);
g2=c2=0;
for(j=0;j<ss;++j)if(s[j]=='G')g2++;else if(s[j]=='C')c2++;
a[i]=g1*c2+g2*c1;
}
for(i=0;i<n;++i)
{
if(maxx<a[i])
{
maxx=a[i];
ans=i+1;
}
}
cout<<ans;
}
return 0;
}
```

### second solution

```
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 14;
int n;
map<char, int> cnt[maxn];
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
int mx = 0, cer = 1;
for(int i = 0; i <= n; i++){
int m;
cin >> m;
string s;
cin >> s;
for(auto c : s)
cnt[i][c]++;
if(i && cnt[i]['C'] * cnt[0]['G'] + cnt[i]['G'] * cnt[0]['C'] > mx){
mx = cnt[i]['C'] * cnt[0]['G'] + cnt[i]['G'] * cnt[0]['C'];
cer = i;
}
}
cout << cer << '\n';
}
```

## 0 Comments