#include #include #include #include #include #include // Yukicoder №424 立体迷路 // https://yukicoder.me/problems/no/424 // *********************** // for debug #define DEBUGs #define NOP do{}while(0) #ifdef DEBUG #define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0) #define TRACECR do{putchar_unlocked('\n');fflush(stdout);}while(0) #else #define TRACE(...) NOP #define TRACECR NOP #endif #define PRINCR putchar_unlocked('\n') #define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0) // The out-of-date function #define asctime(...) asctime_s(...) #define ctime(...) ctime_s(...) #define strlen(a) mystr_len(a) //#define fopen(...) fopen_s(...) //#define freopen(...) freopen_s(...) //#define rewind(a) fseek(a,0L,SEEK_SET) //#define setbuf(a,b) setvbuf(a,b,_IOFBF,BUFSIZ) // for stdio #define GETLINE(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0) #define mygc(c) (c)=getchar() static char *GETWORD( char* str ); static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];c=getchar_unlocked();while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=getchar_unlocked();}*cp='\0';return &str[0];} #define GETINTS(a,b) {char s[34];int *ap=a;REP(i,b){GETWORD(s);*ap++=atoi(s);}} static int GETLINEINT(void) {char s[34];GETLINE(s);return atoi(s);} static int GETWORDINT(void) {char s[34];GETWORD(s);return atoi(s);} #define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0) static int max(int a,int b){if(a>b){return a;}return b;} static int min(int a,int b){if(a*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} static int cmpint_desc(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} static int cmpchar_asc(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} static int cmpchar_desc(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;} static int mystr_len(char *str){int i=0;do{if(str[i]=='\0')break;i++;if(i>9999)break;}while(1);return i;} static int countchar(char str[],char c,int limit ) {int cnt = 0;for(int i=0;i= 0) { xypop( &y, &x ); walking( y, x ); } } return; } // *********************** int main() { int h,w; int sx,sy; int gx,gy; h = GETWORDINT(); w = GETWORDINT(); sy = GETWORDINT() +1; sx = GETWORDINT() +1; goaly = gy = GETWORDINT() +1; goalx = gx = GETWORDINT() +1; REP(i,h+4) { MAP[i][0] = 29 +'0'; MAP[i][1] = 29 +'0'; MAP[i][w+2] = 29 +'0'; MAP[i][w+3] = 29 +'0'; } REP(i,w+2) { MAP[0][i] = 29 +'0'; MAP[1][i] = 29 +'0'; MAP[h+2][i] = 29 +'0'; MAP[h+3][i] = 29 +'0'; } REP(y,56) REP(x,56) MAPUSE[y][x] = 0; // 使用フラグ REP1(y,h) { REP1(x,w) { char c; c=getchar_unlocked(); while( (c > '9')||( c < '0') ) c=getchar_unlocked(); MAP[y+1][x+1] = c ; } } //----- while(0){ REP(y,h+4) { REP(x,w+4) { if( (y==sy)&&(x==sx) ) putchar_unlocked('S'); else if( (y==gy)&&(x==gx) ) putchar_unlocked('G'); else putchar_unlocked( MAP[y][x] ); } putchar_unlocked('\n'); } fflush(stdout); break; } MAPUSE[gy][gx] = 2; MAPUSE[sy][sx] = 1; walking(sy,sx); YES( finish ); PRINCR; return 0; }