1 条题解
-
0
C++ :
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #define INF 1000000000 using namespace std; char a[50]; bool b[150][150]; int main() { int x,y; while(scanf("%d%d",&x,&y)!=EOF) { memset(b,0,sizeof(b)); x=75;y=75; b[x][y]=1; int m; scanf("%d",&m); scanf("%s",a); int flag=0; for(int i=0;i<m;i++) { if(a[i]=='U') { x--; if(b[x][y]==0) b[x][y]=1; else { flag=1; break; } } else if(a[i]=='D') { x++; if(b[x][y]==0) b[x][y]=1; else { flag=1; break; } } else if(a[i]=='L') { y--; if(b[x][y]==0) b[x][y]=1; else { flag=1; break; } } else if(a[i]=='R') { y++; if(b[x][y]==0) b[x][y]=1; else { flag=1; break; } } } if(flag==1) printf("Yes\n"); else printf("No\n"); } }
- 1
信息
- ID
- 990
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- (无)
- 递交数
- 0
- 已通过
- 0
- 上传者