-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZUBREACH.cpp
50 lines (45 loc) · 943 Bytes
/
ZUBREACH.cpp
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
#include<iostream>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
int cnt=1;
int main()
{
int t;
cin>>t;
while(t--)
{
int m,n,rx,ry,len;
cin>>m>>n;
cin>>rx>>ry;
cin>>len;
string s;
cin>>s;
len=s.length();
int xCord=0,yCord=0;
for(int i=0;i<len;i++)
{
if(s[i]=='U')
yCord++;
else if(s[i]=='D')
yCord--;
else if(s[i]=='R')
xCord++;
else if(s[i]=='L')
xCord--;
}
if(rx==xCord&&ry==yCord)
{
cout<<"Case "<<cnt<<": REACHED"<<endl;
}
else if((xCord<0||xCord>m)||(yCord<0||yCord>n))
{
cout<<"Case "<<cnt<<": DANGER"<<endl;
}
else
cout<<"Case "<<cnt<<": SOMEWHERE"<<endl;
cnt++;
}
return 0;
}