#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>> n;
char a[n];
int x=0,y=0;
cin>>a[0];
if(a[0]=='L')
{
x=x-1;
}
else if(a[0]=='R')
{
x=x+1;
}
else if(a[0]=='U')
{
y=y+1;
}
else if(a[0]=='D')
{
y=y-1;
}
for(int i=1;i<n;i++)
{
cin>>a[i];
if(a[i] != a[i-1])
{
if(a[i]=='L')
{
x=x-1;
}
else if(a[i]=='R')
{
x=x+1;
}
else if(a[i]=='U')
{
y=y+1;
}
else if(a[i]=='D')
{
y=y-1;
}
else{
x=x;
y=y;}
}
else{
x=x;
y=y;}
}
cout<<x<<" "<<y<<endl;
}
Please Help.
What is wrong in it?
// your code goes here
return 0;
}