Atcoder 2020/8/22 线上赛 D题题解
Problem Statement
给你一个N*M的字符矩阵,其中字符#表示墙,字符 . . .表示道路
有一个魔术师在(s1,s2),他需要到达(t1,t2)。
他可以做以下两种动作:
移动A:步行到一个与他当前所在广场垂直或水平相邻的道路广场。
招式B:使用魔法将自己扭曲到5×5区域的一个道路广场,该区域以他当前所在的广场为中心。
求的是魔术师到达(t1,t2)需要的最少使用魔法次数
原题链接 https://atcoder.jp/contests/abc176/tasks/abc176_d
实现代码
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int s1,s2,t1,t2;
char a[1005][1005];
bool b[1005][1005];
int dp[1005][1005];
int h[5]={
-1,0,1,0},l[5]={
0,-1,0