1 solutions
-
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
Information
- ID
- 19282
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By