FZU-2150 Fire Game(暴力+広捜)
19878 ワード
テーマリンク:http://acm.fzu.edu.cn/problem.php?pid=2150クリックしてリンクを開く
Problem 2150 Fire Game
Accept:2540 Submit:8781 Time Limit:1000 mSec メモリLimit:32768 KB
Problem Description
Fat breother and Maze ararare playing a kind of special game on n*M board(N rows,M columns).At the begining、each grids of thisboard is is consisting of grasor just juseemipty and then thethethe thethe the the theyfistststrerereredededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededew,the fire can spread among the grass.If the grid(x,y)is firing at time t,the grid whihihich is adjacent to thisgrisgrid will fire at+1 which refersto the grid(x+1,y),(x+1,y),(x-1,x-1,x))ininininininininininininininininininininine e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e ing of grass is get fired、Fat broother and Maze will stand in the middle of the grid and playing a MORE special game.(Maybot’s the OOXX game which decrypted in the last proble,who knows.)
You can asome that the grass in the board would never out and the empy grid would never get fire.
Note that the two grids the y chose can be the same.
Input
The first line of the date is an integer T,which is the number of the text cases.
The n T cases follow、each case contains two integers N and M indicate the size of the board.The n goes N line、each line with M character shows the board.「噗」Indicates the grass.Youcant.Youcant.com the stress Indicates.
1<=T<=100,1<=n==10,1<=m<=10
Output
For each case,output the case number first,if they can play the MORE special game(hentai)game(fire all the grast)、output the minimal time the y need to wait after the set fire,ot the.put.put.put.put.put
Sample Input
43.シ.ハ.ハ.ハ.ハ.ハ.ハ.ハ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.ハ.3…シ.ハ.シ…3ハ.シ
Sample Output
Case 1:1 Case 2:-1 Case 3:0 Case 4:2
いいテーマがfzuだった.良くないことは何もないです.サーバーemmです.
最初にこの問題を手に入れたら面倒くさいと思います.分類して検討しなければなりません.
草の接続度を確定するのは1であるかもしれません. 2 >2
1のために2つの起点を暴力的に検索し、最小のステップ数を探す(2枚の図は2つの火元のステップ数を記録する).
2つの点をそれぞれに分けて検索する場合は、この時点で最も速く蔓延する全ての方法を探す(最初はxy方向の最大位置最小位置だけを判断する必要があると思っていたが、後には間違っていた.蔓延方法は1つしかないかもしれないので)も同じです. 広く一つ一つの点を検索して列挙する.
とするなら -1
そして午後にかけました.コード長の恐怖
そして題解を検索したら、直接に12合併暴力を二つの点に検索すればいいです.
もちろん最初はこういう考え方が鍛えられました.捜索に対する能力はwarchessとこの問題を経験してから明らかに向上しました.
ほらを吹いてはいけません.
先に12000 bコードを払います
縮めるのがみっともないです.誰も見ていないでしょう.
Problem 2150 Fire Game
Accept:2540 Submit:8781 Time Limit:1000 mSec メモリLimit:32768 KB
Problem Description
Fat breother and Maze ararare playing a kind of special game on n*M board(N rows,M columns).At the begining、each grids of thisboard is is consisting of grasor just juseemipty and then thethethe thethe the the theyfistststrerereredededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededew,the fire can spread among the grass.If the grid(x,y)is firing at time t,the grid whihihich is adjacent to thisgrisgrid will fire at+1 which refersto the grid(x+1,y),(x+1,y),(x-1,x-1,x))ininininininininininininininininininininine e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e e ing of grass is get fired、Fat broother and Maze will stand in the middle of the grid and playing a MORE special game.(Maybot’s the OOXX game which decrypted in the last proble,who knows.)
You can asome that the grass in the board would never out and the empy grid would never get fire.
Note that the two grids the y chose can be the same.
Input
The first line of the date is an integer T,which is the number of the text cases.
The n T cases follow、each case contains two integers N and M indicate the size of the board.The n goes N line、each line with M character shows the board.「噗」Indicates the grass.Youcant.Youcant.com the stress Indicates.
1<=T<=100,1<=n==10,1<=m<=10
Output
For each case,output the case number first,if they can play the MORE special game(hentai)game(fire all the grast)、output the minimal time the y need to wait after the set fire,ot the.put.put.put.put.put
Sample Input
43.シ.ハ.ハ.ハ.ハ.ハ.ハ.ハ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.シ.ハ.3…シ.ハ.シ…3ハ.シ
Sample Output
Case 1:1 Case 2:-1 Case 3:0 Case 4:2
いいテーマがfzuだった.良くないことは何もないです.サーバーemmです.
最初にこの問題を手に入れたら面倒くさいと思います.分類して検討しなければなりません.
草の接続度を確定するのは1であるかもしれません. 2 >2
1のために2つの起点を暴力的に検索し、最小のステップ数を探す(2枚の図は2つの火元のステップ数を記録する).
2つの点をそれぞれに分けて検索する場合は、この時点で最も速く蔓延する全ての方法を探す(最初はxy方向の最大位置最小位置だけを判断する必要があると思っていたが、後には間違っていた.蔓延方法は1つしかないかもしれないので)も同じです. 広く一つ一つの点を検索して列挙する.
とするなら -1
そして午後にかけました.コード長の恐怖
そして題解を検索したら、直接に12合併暴力を二つの点に検索すればいいです.
もちろん最初はこういう考え方が鍛えられました.捜索に対する能力はwarchessとこの問題を経験してから明らかに向上しました.
ほらを吹いてはいけません.
先に12000 bコードを払います
縮めるのがみっともないです.誰も見ていないでしょう.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
そしてこれは爆捜です.#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include