-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestRobot.c
More file actions
59 lines (56 loc) · 928 Bytes
/
Copy pathtestRobot.c
File metadata and controls
59 lines (56 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//testing robot
#include <stdio.h>
#include <string.h>
void removeDuplicates( int arr[],int n)
{
int i,j,k;
int count=1;
for(i=1; i<n; i++)
{
j=0;
for(j=0; j<i; j++)
{
if(arr[i] == arr[j])
{
break;
}
}
if(i==j)
count++;
}
printf("%d\n",count);
}
int main(void) {
char str[100];
int t;
scanf("%d",&t);
while(t--)
{
int n;
long long int x;
int count=0;
scanf("%d",&n);
scanf("%lld",&x);
int arr[n+1];
memset(arr,0,sizeof(arr));
count++;
int i;
int j=0;
scanf("%s",str);
for(i=0;i<=n;i++)
{
if(str[i]=='L')
{
int t=x--;
arr[j++]=t;
}
else
{
int t1 = x++;
arr[j++]=t1;
}
}
removeDuplicates(arr,j);
}
return 0;
}