hdu 1429勝利大逃亡 續

2021-06-01 13:46:30 字數 1168 閱讀 7515

題目:

一開始想了好幾種方法。。最後實驗都錯了。。

要麼是就是演算法思想錯誤。。

然後以為可以這樣。。果斷。。記憶體超出。

下面是錯誤**。。。

#include#include#includeusing namespace std;

#define n 21

int n,m,t;

char map[n][n];

bool visited[n][n];

struct node

;int next[4][2]=,,,};

node s_pos,e_pos;

int flag;

int cheak(int x,int y)

for( i=0;i<4;i++)

if((map[x][y]>='a'&&map[x][y]<='j'))

if(map[x][y]>='a'&&map[x][y]<='j')}}

} }

} int main()

if(map[i][j]=='^')

if(map[i][j]=='*')

wall++;

}int temp=e_pos.x-s_pos.x+e_pos.y-s_pos.y;

flag=0;

if(temp>t)

printf("-1\n");

else

} return 0;

}

下面是ac**:

#include#includeusing namespace std;

struct node

;int dir[4][2]=;

int binary[26]=;

char gra[21][21];

int flag[21][21][2049];

int m,n,t;

int sx,sy,ex,ey;

void bfs()

}else if(gra[p.x][p.y] >= 'a' && gra[p.x][p.y] <= 'j')

}else }}

}//for(k=0;k<4;k++)

}//while(!q.empty())

cout<<-1<>m>>n>>t)

{for(i=0;i

HDU1429 勝利大逃亡 續

學習位壓縮很好的一道題,因為只有10把鑰匙,那麼可以把10鑰匙壓縮二進位制,比如1000就表示身上只要第4把鑰匙的狀態,110表示帶有第2把和第3把鑰匙,那麼要判斷當前的鑰匙串有沒有能開啟當前門鑰匙,那麼就只要乙個 運算就可以,因為11101110 00100000 00100000 這樣就說明那一...

hdu 1429 勝利大逃亡 續

code include include using namespace std struct px struct px start char map 25 25 int mark 25 25 1025 dir 4 2 三維表,走過的路徑對應表的狀態 int wys 10 int n,m,t boo...

hdu1429 勝利大逃亡 續

讓我初識位壓縮的一道bfs題,之前採用結構中增加char型別的key 26 然後採用陣列對映實現對鑰匙的儲存,交上去悲劇地mle了,然後在yhl大牛的部落格上發現了位壓縮這一好東東,現在和大家分享一下 用二進位制來表示手頭的鑰匙有哪些,100表示有第三把鑰匙,111表示有第 三 二 一把,搜尋下一點...