csu1511 殘缺的棋盤(bfs)

2021-07-31 11:24:27 字數 874 閱讀 2252

input

輸入包含不超過10000 組資料。每組資料報含6個整數r1, c1, r2, c2, r3, c3 (1<=r1, c1, r2, c2, r3, c3<=8). 三個格仔a, b, c保證各不相同。

output

對於每組資料,輸出測試點編號和最少步數。

sample input

1 1 8 7 5 6

1 1 3 3 2 2

sample output

case 1: 7

case 2: 3

簡單的bfs,第三個點處理成不能走就行了

#include 

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#define inf 0x3f3f3f3f

#define maxn 100005

#define mod 1000000007

using

namespace

std;

int r1,c1,r2,c2,r3,c3;

int vis[10][10];

int dx=;

int dy=;

struct node

;int bfs(int x,int y)

for(int i=0;i<8;++i)

}}int main()

return

0;}

CSUOJ 1511 殘缺的棋盤

time limit 1 sec memory limit 128 mb submit 169 solved 56 submit status web board 輸入包含不超過10000 組資料。每組資料報含6個整數r1,c1,r2,c2,r3,c3 1 r1,c1,r2,c2,r3,c3 8 三...

殘缺的棋盤(BFS)

一道bfs版題,留一下方便以後 在西洋棋裡,王是最重要的乙個棋子。每一步,王可以往上下左右或者對角線方向移動一 步,如下圖所示。給定兩個格仔 a r1,c1 b r2,c2 你的任務是計算出乙個王從 a 到 b 至少需要走多少步。為了避免題目太簡單,我們從棋盤裡拿掉了乙個格仔 c r3,c3 abc...

殘缺的棋盤 (BFS)

在西洋棋裡,王是最重要的乙個棋子。每一步,王可以往上下左右或者對角線方向移動一步,如下圖所示 給定兩個格仔 a r1c1 b r2c2 你的任務是計算出乙個王從 a到 b至少需要走多少步。為了避免題目太簡單,我們從棋盤裡拿掉了乙個格仔 c r3c3 abc保證互不相同 要求王從 a走到 b的過程中不...