manalibiswas's blog

By manalibiswas, history, 5 years ago, In English

include<bits/stdc++.h>

using namespace std;

void find(char m,int&p,int&q) { if(m=='W') ++p; else ++q; } int main() { int n,k,i,p,q; char x; vector a; cin>>n>>k;

for(int i=0;i<n;i++)
{
    cin>>x;
    a.push_back(x);
}
a.push_back('\0');

for(int l=0,i=0;l<k&&i<n;l++)
{
    vector<char>b;
    for(int j=0;j<n;j++)
    {p=q=0;
        if(j==0)
        {
            find(a[n-1],p,q);
            find(a[0],p,q);
            find(a[1],p,q);
        }
        else if(j==(n-1))
        {
            find(a[0],p,q);
            find(a[n-1],p,q);
            find(a[n-2],p,q);
        }
        else
        {
            find(a[j-1],p,q);
            find(a[j+1],p,q);
            find(a[j],p,q);
        }
        b.push_back(p>q?'W':'B');
        if(a[j]==b[j]) i++;
    }
    b.push_back('\0');
    a=b;
}
for(int j=0;j<n;j++)
    cout<<a[j];
cout<<'\0';
return 0;

}

This is my submission for the problem.. Even the wrong test case on first test case shows right answer but still showing wrong answer? And showing right answer for the example cases on other interfaces but not here

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it