labyrinth

dfs剪枝

一世执手 提交于 2020-01-26 22:25:01
Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of the bomb is set to 6 minutes. To prevent the bomb from exploding by shake, Ignatius had to move slowly, that is to move from one area to the nearest area(that is, if Ignatius stands on (x,y) now, he could only on (x+1,y), (x-1,y), (x,y+1), or (x,y-1) in the next minute) takes him 1 minute. Some area in the labyrinth contains a Bomb-Reset-Equipment. They could reset the exploding

Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) E. Rock Is Push dp

回眸只為那壹抹淺笑 提交于 2019-12-03 07:02:05
E. Rock Is Push You are at the top left cell (1,1) of an n×m labyrinth. Your goal is to get to the bottom right cell (n,m). You can only move right or down, one cell per step. Moving right from a cell (x,y) takes you to the cell (x,y+1), while moving down takes you to the cell (x+1,y). Some cells of the labyrinth contain rocks. When you move to a cell with rock, the rock is pushed to the next cell in the direction you're moving. If the next cell contains a rock, it gets pushed further, and so on. The labyrinth is surrounded by impenetrable walls, thus any move that would put you or any rock

Labyrinth CodeForces - 1063B (0-1最短路)

匿名 (未验证) 提交于 2019-12-02 23:26:52
传送门 题意:从起点开始最多能向左走L步,最多能向右走R步,问最多能覆盖图上多少个点? 题解:参考 ysl的题解 ,先进行变量代换,之后使用0-1最短路的deque算法即可。 附上代码: #include<bits/stdc++.h> using namespace std; struct node{ int x,y; node(int x=0,int y=0):x(x),y(y){} }; int n,m,r,c,x,y; const int maxn=2000+10; const int inf=0x3f3f3f3f; char g[maxn][maxn]; int dis[maxn][maxn]; int dx[]={0,0,-1,1}; int dy[]={-1,1,0,0}; void bfs(){ deque<node> q; q.push_front(node(r-1,c-1)); memset(dis,inf,sizeof dis); dis[r-1][c-1]=0; while(!q.empty()){ node tmp=q.front(); q.pop_front(); for(int i=0;i<4;i++){ int tx=tmp.x+dx[i]; int ty=tmp.y+dy[i]; if(tx<0||tx>=n||ty<0||ty>=m||g[tx]

Labyrinth【BFS+优先队列】

匿名 (未验证) 提交于 2019-12-02 22:56:40
题面 You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c . In one step you can move one square up, left, down or right, if the target cell is not occupied by an obstacle. You can't move beyond the boundaries of the labyrinth. Unfortunately, your keyboard is about to break, so you can move left no more than x times and move right no more than y times. There are no restrictions on the number of moves up and down since the