It is a C++ code for the practice question “Testing the robot”
The link to the problem is “TSTROBOT Problem - CodeChef”
#include
using namespace std;
int main()
{
int y=0;
int n;
int c=0;
int x;
cin>>n>>x;
int m=0;
char com[100];
for(int i=0;i<n;i++)
{
cin>>com[i];
}
for(int j=0;j<n;j++)
{
if(com[j]==‘L’)
{
c=c+1;
}
else
{
y=y+1;
}
}
if(c>y)
{
m=(c-y)+y;
}
else if(y>c)
{
m=(y-c)+c;
}
else
{
m=c;
}
cout<<“the number of distinct points visited is”<<m+1;
return 0;
}