#include
#include
using namespace std;
char move_black(char);
char move_white(char);
char get_ans(int);
char init=‘A’;
char fin;
int main() {
long long int t,i,w;
vector<int>x;
cin>>t;
for(i=0;i<t;i++)
{
scanf("%d",&w);
x.push_back(w);
}
auto h=x.begin();
for(auto i=x.begin();i!=x.end();++i)
{
printf("%c\n",get_ans(*h));
}
return 0;
}
char get_ans(int num)
{
vectorm;
int i=num;
while(i/10!=0)
{
m.push_back(i%10);
i=i/10;
}
m.push_back(i);
for(i=0;i<m.size();i++)
{
for(int it=0;it<m[i];it++)
{
init=move_black(init);
}
init=move_white(init);
}
return init;
}
// your code goes here
char move_white(char x)
{
if(x=='A')
return 'A';
else if(x=='B')
return 'C';
else if(x=='C')
return 'D';
else if(x=='D')
return 'F';
else if(x=='F')
return 'E';
else if(x=='E')
return 'G';
else if(x=='G')
return 'B';
}
char move_black(char x)
{
if(x=='A')
return 'B';
else if(x=='B')
return 'D';
else if(x=='D')
return 'C';
else if(x=='C')
return 'E';
else if(x=='E')
return 'G';
else if(x=='G')
return 'F';
else if(x=='F')
return 'A';
}
What is wrong with my code?
I am able to pass initial test case but on subtion it is showing wrong answer.