1244F Chips showing wrong answer although compiling correctly on all other interfaces

Revision en1, by manalibiswas, 2019-10-15 08:49:31

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

Tags 1244f

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English manalibiswas 2019-10-15 08:49:31 1422 Initial revision (published)