Simulation, test instructions looked for an hour
/************************************************author:zhou zhentaoemail: [Email protected]created Tim E:2015/12/15 13:19:28file name:main.cpp*************************************************/#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<stdlib.h>#include<time.h>using namespacestd;Const intmaxn= -+Ten;intMAP[MAXN][MAXN];Chars[100000+Ten];intans[100000+Ten];intr,c,x,y;BOOLPintXinty) { if(x>=1&&x<=R) {if(y>=1&&y<=C) {return 1; } } return 0;}intMain () { while(~SCANF ("%d%d",&r,&C) {memset (Map,0,sizeofMap); scanf ("%d%d",&x,&y); Map[x][y]=1; ans[0]=1; scanf ("%s", s); intlen=strlen (s); for(intI=0; i<len; i++) { if(i==len-1) { intnum=0; for(intI=1; i<=r; i++) { for(intj=1; j<=c; J + +) { if(map[i][j]==0) num++; }} ans[i+1]=num; Break; } Else { intNewx,newy; if(s[i]=='U') {newx=x-1; Newy=y; } Else if(s[i]=='D') {newx=x+1; Newy=y; } Else if(s[i]=='L') {newx=x; Newy=y-1; } Else if(s[i]=='R') {newx=x; Newy=y+1; } if(P (Newx,newy)) {x=newx; Y=Newy; if(map[newx][newy]==0) {Map[x][y]=1; Ans[i+1]=1; } Elseans[i+1]=0; } Elseans[i+1]=0; } } for(intI=0; i<=len; i++) {printf ("%d", Ans[i]); if(I<len) printf (" "); Elseprintf"\ n"); } } return 0;}
Codeforces 606B Testing Robots