题解
2023-07-10 17:40:33
发布于:上海
18阅读
0回复
0点赞
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
const int N=1e3+3,inf=2147483647;
int n,m,q,x,y;
char a[N][N];
string s;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
cin>>s;
q=s.length();
x=y=1;
for(int i=0;i<q;i++){
if(s[i]=='T'){
y--;
if(y==0){
y++;
printf("NO Way!\n");
}
else if(a[y][x]=='X')printf("I Can do win!\n");
else printf("I Can\n");
}
else if(s[i]=='D'){
y++;
if(y==n+1){
y--;
printf("NO Way!\n");
}
else if(a[y][x]=='X')printf("I Can do win!\n");
else printf("I Can\n");
}
else if(s[i]=='L'){
x--;
if(x==0){
x++;
printf("NO Way!\n");
}
else if(a[y][x]=='X')printf("I Can do win!\n");
else printf("I Can\n");
}
else if('R'){
x++;
if(x==m+1){
x--;
printf("NO Way!\n");
}
else if(a[y][x]=='X')printf("I Can do win!\n");
else printf("I Can\n");
}
}
return 0;
}
这里空空如也
有帮助,赞一个