• <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 <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>

            int  num[9], ini;
            int  L;
            bool flag;
            int  mv[4= {13-1-3};//right down left up
            int  path[1001];
            int  len;
            char map[4= {'r''d''l''u'};

            void read()
            {
                
            char s[2];
                
            for(int i = 0; i < 9; i ++)
                {
                    scanf(
            "%s", s);
                    
            if(s[0== 'x') {num[i] = 0; ini = i;}
                    
            else            num[i] = s[0- '0';
                }
            }

            bool ok()   // jud for destination
            {
                
            for(int i = 0; i < 8; i ++)
                    
            if(num[i] != i + 1return false;
                
            return true;
            }

            bool jud(int pos, int i)  //jud for right
            {
                
            if(pos % 3 != 2 && i == 0return true;
                
            if(pos < 6 && i == 1return true;
                
            if(pos % 3 != 0 && i == 2return true;
                
            if(pos > 2 && i == 3return true;
                
            return false;
            }

            int cal()
            {
                
            int cost = 0;
                
            for(int i = 0; i < 9; i ++)
                
            if(num[i])
                    cost 
            += abs((num[i] - 1)%3 - i%3+ abs((num[i] - 1)/3 - i/3);
                
            return cost;
            }

            void dfs(int pos, int deep)
            {
                
            int i, J, cost;
                
            if(deep == L)
                {
                    
            if(ok()) flag = true;
                    
            return;
                }
                
            for(i = 0; i < 4; i ++)
                {
                    
            if(!jud(pos, i)) continue;
                    num[pos] 
            ^= num[pos + mv[i]] ^= num[pos] ^= num[pos + mv[i]];//state change
                    
                    cost 
            = cal();
                    
            if(cost + deep  < L)
                    {
                        path[len
            ++= i;
                        dfs(pos 
            + mv[i], deep + 1);
                        
            if(flag) return;
                        len 
            --;
                    }
                    num[pos] 
            ^= num[pos + mv[i]] ^= num[pos] ^= num[pos + mv[i]];//state again
                }    
            }

            void out()
            {
                
            int i;
                
            //printf("%d\n",len);
                for(i = 0; i < len; i ++)
                    printf(
            "%c", map[path[i]]);
                puts(
            "");
            }

            int main()
            {
                read();
                L 
            = 1; len = 0;
                flag 
            = false;
                
            while(!flag)
                {
                    dfs(ini, 
            0);
                    L 
            ++;
                }
                
            out();
            }

            posted on 2009-09-03 01:19 superlong 閱讀(135) 評論(0)  編輯 收藏 引用
            2021国产精品久久精品| 久久夜色撩人精品国产| 中文字幕久久波多野结衣av| 久久婷婷五月综合色奶水99啪| 中文字幕热久久久久久久| 久久精品国产亚洲AV嫖农村妇女 | 久久一区二区三区99| 久久午夜夜伦鲁鲁片免费无码影视| 久久久噜噜噜www成人网| 久久99亚洲综合精品首页| 亚洲精品乱码久久久久66| 91久久国产视频| 久久久久亚洲AV成人片| 日韩AV毛片精品久久久| 久久精品免费观看| 久久亚洲精品中文字幕| 久久亚洲欧洲国产综合| 久久综合综合久久97色| 久久久久久国产精品无码下载| 99久久国产综合精品五月天喷水 | 国产V综合V亚洲欧美久久| 国产69精品久久久久观看软件| 狠狠色丁香婷综合久久| 久久夜色精品国产噜噜麻豆| 亚洲日本久久久午夜精品| 久久久中文字幕日本| 精品国产91久久久久久久a| 久久精品无码专区免费青青| 欧美伊人久久大香线蕉综合 | 中文字幕无码av激情不卡久久| 国产亚州精品女人久久久久久| 国产成人久久激情91| 国产亚洲欧美成人久久片| 精品久久久久久久久午夜福利| 久久久久久久久波多野高潮| 久久精品免费全国观看国产| 老男人久久青草av高清| 久久亚洲AV无码精品色午夜| 熟妇人妻久久中文字幕| 亚洲第一极品精品无码久久| 亚洲精品乱码久久久久久自慰|