forked from shauryas1ngh/codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGIFTSRC.cp
More file actions
70 lines (58 loc) · 1013 Bytes
/
GIFTSRC.cp
File metadata and controls
70 lines (58 loc) · 1013 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
59
60
61
62
63
64
65
66
67
68
69
70
using namespace std;
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
struct point
{
int x;
int y;
};
void left(point &p)
{
p.x=p.x-1;
}
void right(point &p)
{
p.x=p.x+1;
}
void up(point &p)
{
p.y=p.y+1;
}
void down(point &p)
{
p.y=p.y-1;
}
int main()
{
int t;
cin>>t;
while(t--)
{
point p;
p.x=0;p.y=0;
int n;
cin>>n;
char s='0',z;
for(int i=0;i<n;i++)
{
cin>>z;
if((s=='L' || s=='R') && (z=='L' || z=='R'))
continue;
else if((s=='U' || s=='D') &&( z=='U' || z=='D'))
continue;
else
s=z;
if(s=='L')
left(p);
else if(s=='R')
right(p);
else if(s=='U')
up(p);
else if(s=='D')
down(p);
}
cout<<p.x<<" "<<p.y<<"\n";
}
return 0;
}