# Help me in solving BLAST3 problem

### My issue

Please can anyone help me, why my solution doesn’t work? The intution idea is similar to the idea of the author’s solution, but I have implemented it differently.

### My code

``````#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
ll t,n,i,j,k;
cin >> t;
while(t--)
{
cin >> n;
string s1;
cin >> s1;
if(n%3==1)
{
cout << "YES\n";
continue;
}
map<char,pair<ll,ll>>m1;
for(auto x:s1)
{
m1[x]=make_pair(0ll,0ll);
}
if(n%3==0)
{
for(i=0;i<n;i++)
{
if((i+1)%3==1)
m1[s1[i]].first=1ll;
else if((i+1)%3==0)
m1[s1[i]].second=1ll;
}
}
else
{
for(i=0;i<n;i++)
{
if((i+1)%3==1)
m1[s1[i]].first=1ll;
else if((i+1)%3==2)
m1[s1[i]].second=1ll;
}
}
ll f=0ll;
for(auto x:m1)
{
// cout << x.first << "->" << x.second.first << ", "<< x.second.second << "\n";
if(((x.second).first==1) && ((x.second).second==1))
{
f=1ll;
// cout << x.first<< " ";
break;
}
}
if(f==1ll)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
``````

Problem Link: BLAST3 Problem - CodeChef

Edit: Sorry, I have found out about my mistake.

In the above solution, the test case for string ‘bcaade’ will give us an answer as ‘YES’, but the actual output is ‘NO’. Because even though we have 2 as indices, at idx = 2, (idx+1)%3 = 0, and at idx = 3, (idx+1)%3 = 1. The solution should be NO.