注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
同学在google foobar上的一道题, 提交时候一直是400 bad request,估计是超时了,分享给我题目和他的解法,求优化
Prepare the Bunnies' Escape
===========================
You're awfully close to destroying the LAMBCHOPdoomsday device and freeing Commander Lambda's bunny prisoners, but oncethey're free of the prison blocks, the bunnies are going to need to escapeLambda's space station via the escape pods as quickly as possible.Unfortunately, the halls of the space station are a maze of corridors and deadends that will be a deathtrap for the escaping bunnies. Fortunately, CommanderLambda has put you in charge of a remodeling project that will give you theopportunity to make things a little easier for the bunnies. Unfortunately(again), you can't just remove all obstacles between the bunnies and the escapepods - at most you can remove one wall per escape pod path, both to maintainstructural integrity of the station and to avoid arousing Commander Lambda'ssuspicions.
You have maps of parts of the space station, each starting at a prison exit andending at the door to an escape pod. The map is represented as a matrix of 0sand 1s, where min = Math.min(dfs(nx, ny, allowRemove, visited, maze, len + 1), min); }else if(allowRemove){ min = Math.min(dfs(nx, ny, false, visited, maze, len + 1), min); } if(min == maze.length + maze[0].length - 1){ break; } } visited[x][y] = false; return min; }
|