-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1121.cpp
More file actions
95 lines (86 loc) · 1.6 KB
/
1121.cpp
File metadata and controls
95 lines (86 loc) · 1.6 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int main()
{
while(~scanf("%d%d%d",&n,&m,&k))
{
int x,y;
char dir;
if(!n && !m && !k)break;
int s[n][m];
for(int i=0;i<n;i++)
{
scanf(" %[^\n]",s[i]);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='O' || s[i][j]=='L' || s[i][j]=='S' || s[i][j]=='N')
{
dir = s[i][j];
x=i;
y=j;
break;
}
}
}
int ans=0;
char sz[k+1];
scanf(" %[^\n]",sz);
for(int i=0;i<k;i++)
{
printf("susu\n");
if(sz[i] == 'E')
{
dir = dir=='N'? 'O' : dir=='O'? 'S' : dir == 'S'? 'L' : 'N';
}
else if(sz[i]=='D')
{
dir = dir=='N'? 'L' : dir == 'L'? 'S' : dir =='S'? 'O' : 'N';
}
else if(sz[i]=='F')
{
if(s[x][y]=='N')
{
if(x>0 && s[x-1][y]!='#')
{
if(s[x-1][y] == '*')ans++;
s[x-1][y]='N';
x--;
}
}
else if(s[x][y]=='O')
{
if(y>0 && s[x][y-1]!='#')
{
if(s[x][y-1] == '*')ans++;
s[x][y-1]='O';
y--;
}
}
else if(s[x][y]=='S')
{
if(x<n-1 && s[x+1][y]!='#')
{
if(s[x+1][y] == '*')ans++;
s[x+1][y]='S';
x++;
}
}
else if(s[x][y]=='L')
{
if(y<m-1 && s[x][y+1]!='#')
{
if(s[x][y+1] == '*')ans++;
s[x][y+1]='L';
y++;
}
}
}
}
printf("%d\n",ans);
}
return 0;
}