• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            學習心得(code)

            superlong@CoreCoder

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

            公告

            文字可能放在http://blog.csdn.net/superlong100,此處存放代碼

            常用鏈接

            留言簿(4)

            我參與的團隊

            搜索

            •  

            最新隨筆

            最新評論

            • 1.?re: Poj 1279
            • 對于一個凹多邊形用叉積計算面積 后能根據結果的正負來判斷給的點集的時針方向?
            • --bsshanghai
            • 2.?re: Poj 3691
            • 你寫的這個get_fail() 好像并是真正的get_fail,也是說fail指向的串并不是當前結點的子串。為什么要這樣弄呢?
            • --acmer1183
            • 3.?re: HDU2295[未登錄]
            • 這個是IDA* 也就是迭代加深@ylfdrib
            • --superlong
            • 4.?re: HDU2295
            • 評論內容較長,點擊標題查看
            • --ylfdrib
            • 5.?re: HOJ 11482
            • 呵呵..把代碼發在這里很不錯..以后我也試試...百度的編輯器太爛了....
            • --csuft1

            閱讀排行榜

            評論排行榜

            #include <iostream>
            #include 
            <queue>
            #include 
            <string>
            using namespace std;

            int r, c;

            char  map[1001][1001];
            bool  hash[1001][1001];
            int   tu[1001][1001];

            void read()
            {
                scanf(
            "%d %d"&r, &c);
                getchar();
                
            for(int i = 0; i < r; i ++) gets(map[i]);
            }

            struct nod
            {
                
            int x, y;
            };

            int move[4][2]={{-10}, {01}, {10}, {0-1}};

            queue 
            <nod> q;

            bool check(nod st)
            {
                
            if(st.x < 0 || st.y < 0 || st.x >=|| st.y >= c)
                    
            return false;
                
            if(map[st.x][st.y] == '#' || map[st.x][st.y] == 'J'return false;
                
            return true;
            }

            void bfs()
            {
                
            int i, j, step = 0, size;
                nod temp, t;
                
            while(!q.empty())
                {
                    size 
            = q.size();
                    
            while(size --)
                    {
                        temp 
            = q.front();
                        q.pop();
                        
            for(i = 0; i < 4; i ++)
                        {
                            t.x 
            = temp.x + move[i][0];
                            t.y 
            = temp.y + move[i][1];     
                            
            if(tu[t.x][t.y] > step + 1 && check(t))
                            {
                                tu[t.x][t.y] 
            = step + 1;
                                q.push(t);
                            }
                        }   
                    }
                    step 
            ++;
                }
            }

            bool final(nod sta)
            {
                
            if(sta.x < 0 || sta.y < 0 || sta.x >= r || sta.y >= c)
                    
            return true;
                
            return false;
            }

            bool ok(nod sta, int step)
            {
                
            if(map[sta.x][sta.y] == '#' || tu[sta.x][sta.y] <= step + 1 || hash[sta.x][sta.y])
                    
            return false;
                
            return true;
            }

            bool expend(nod sta, int step)
            {
                nod t;
                
            for(int i = 0; i < 4; i ++)
                {
                    t.x 
            = sta.x + move[i][0];
                    t.y 
            = sta.y + move[i][1];
                    
            if(final(t))       return true;
                    
            if(ok(t, step))    
                    {
                        hash[t.x][t.y] 
            = 1;
                        q.push(t);
                    }
                }
                
            return false;
            }

            int bfs_person(int x, int y)
            {
                
            int i, j, step = 0, size;
                
            while(!q.empty()) q.pop();
                nod temp, t;
                temp.x 
            = x;
                temp.y 
            = y;
                q.push(temp);
                
            while(!q.empty())
                {
                    size 
            = q.size();
                    
            while(size --)
                    {
                        temp 
            = q.front();
                        q.pop();
                        
            if(expend(temp, step)) return step + 1;
                    }
                    step 
            ++;
                }
                
            return -1;
            }

            void solve()
            {
                
            int i, j, x, y;
                nod tp;
                
            for(i = 0; i < r; i ++)
                
            for(j = 0; j < c; j ++)
                    tu[i][j] 
            = 999999;
                
            while(!q.empty()) q.pop();
                
            for(i = 0; i < r; i ++)
                
            for(j = 0; j < c; j ++)
                {
                    
            if(map[i][j] == 'F')
                    {
                        tp.x 
            = i;    tp.y = j;
                        tu[i][j] 
            = 0;
                        q.push(tp);
                    }
                    
            if(map[i][j] == 'J')
                    {
                        x 
            = i;
                        y 
            = j;
                    }
                }
                bfs();
                
                
            int ans = bfs_person(x, y);
                
            if(ans < 0) puts("IMPOSSIBLE");
                
            else        printf("%d\n",ans);
                
            }

            int main()
            {
                read();
                solve();
            }

            posted on 2009-08-28 20:26 superlong 閱讀(95) 評論(0)  編輯 收藏 引用
            久久99热精品| 三级三级久久三级久久| 蜜桃麻豆www久久| 国产精品亚洲综合专区片高清久久久 | 久久久久一本毛久久久| 热99RE久久精品这里都是精品免费| 中文成人久久久久影院免费观看| 午夜精品久久久久久中宇| 国产福利电影一区二区三区久久老子无码午夜伦不 | 少妇久久久久久被弄到高潮 | 伊人久久精品影院| 亚洲国产精品婷婷久久| 波多野结衣久久| 久久精品国产亚洲av瑜伽| 69SEX久久精品国产麻豆| 狠狠色丁香婷婷久久综合| 久久最近最新中文字幕大全| 亚洲午夜久久久影院伊人| 亚洲欧美国产精品专区久久| 久久美女人爽女人爽| 精品国产乱码久久久久久1区2区 | 久久久一本精品99久久精品88| 激情久久久久久久久久| 99久久99久久精品免费看蜜桃| 99久久夜色精品国产网站| 久久婷婷色香五月综合激情| 久久久精品无码专区不卡| 国产日韩久久久精品影院首页| 国产精品久久久久jk制服| 国产婷婷成人久久Av免费高清| 亚洲色大成网站www久久九| 亚洲精品视频久久久| 三级韩国一区久久二区综合| 久久99精品国产麻豆蜜芽| 国产精品99久久久久久宅男| 亚洲国产天堂久久综合网站| 99久久精品这里只有精品| 精品久久久久久久久久中文字幕 | 国产成人精品久久综合| 精品久久久久久99人妻| 青青青青久久精品国产h久久精品五福影院1421 |