public class RobotOnMoonEasy
{
{
int n = board.length;
int m = board[0].length();
int x = 0, y = 0;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
if(board[i].charAt(j) == 'S')
{
x = i;
y = j;
}
for(int i = 0; i < S.length(); i++)
{
int nx = x, ny = y;
if(S.charAt(i) == 'U') nx --;
if(S.charAt(i) == 'D') nx ++;
if(S.charAt(i) == 'L') ny --;
if(S.charAt(i) == 'R') ny ++;
if(nx < 0 || nx >= n || ny < 0 || ny >= m)
return "Dead";
if(board[nx].charAt(ny) == '#')
continue;
x = nx;
y = ny;
}
return "Alive";
}
}
cHVibGljIGNsYXNzIFJvYm90T25Nb29uRWFzeQp7CglwdWJsaWMgU3RyaW5nIGlzU2FmZUNvbW1hbmQoU3RyaW5nW10gYm9hcmQsIFN0cmluZyBTKQoJewoJCWludCBuID0gYm9hcmQubGVuZ3RoOwoJCWludCBtID0gYm9hcmRbMF0ubGVuZ3RoKCk7CgkJaW50IHggPSAwLCB5ID0gMDsKCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJCQlmb3IoaW50IGogPSAwOyBqIDwgbTsgaisrKQoJCQkJaWYoYm9hcmRbaV0uY2hhckF0KGopID09ICdTJykKCQkJCXsKCQkJCQl4ID0gaTsKCQkJCQl5ID0gajsKCQkJCX0KCQlmb3IoaW50IGkgPSAwOyBpIDwgUy5sZW5ndGgoKTsgaSsrKQoJCXsKCQkJaW50IG54ID0geCwgbnkgPSB5OwoJCQlpZihTLmNoYXJBdChpKSA9PSAnVScpIG54IC0tOwoJCQlpZihTLmNoYXJBdChpKSA9PSAnRCcpIG54ICsrOwoJCQlpZihTLmNoYXJBdChpKSA9PSAnTCcpIG55IC0tOwoJCQlpZihTLmNoYXJBdChpKSA9PSAnUicpIG55ICsrOwoJCQlpZihueCA8IDAgfHwgbnggPj0gbiB8fCBueSA8IDAgfHwgbnkgPj0gbSkKCQkJCXJldHVybiAiRGVhZCI7CgkJCWlmKGJvYXJkW254XS5jaGFyQXQobnkpID09ICcjJykKCQkJCWNvbnRpbnVlOwoJCQl4ID0gbng7CgkJCXkgPSBueTsKCQl9CgkJcmV0dXJuICJBbGl2ZSI7Cgl9Cn0K