• <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>

            巢穴

            about:blank

            P1753

              -_-||| 
              一直runtime error
               然后再poj上找到了數(shù)據(jù)
               測試數(shù)據(jù)正確
               于是懷疑是我用<map>的問題,疑惑不解中
            #include <iostream>
            #include 
            <string>
            #include 
            <map>
            #include 
            <queue>
            using namespace std;

            queue
            <string> list; 
            queue
            <int> list_t;
            map
            <string,int> hash;

            void init()
            {
                 
                 
            string str="";
                 
            for (int i=0;i<4;i++)
                 
            {
                     
            for (int j=0;j<4;j++)
                     
            {
                         
            char ch;
                         cin
            >>ch;
                         
            //ch=getchar();
                         str+=ch;
                     }

                     getchar();
                 }


                 
            if (str=="bbbbbbbbbbbbbbbb"||str=="wwwwwwwwwwwwwwww")
                 
            {
                        cout
            <<0<<endl;
                        exit(
            0);
                 }
             
                 list.push(str);
                 list_t.push(
            0);
                 hash.insert(map
            <string,int>::value_type(str,0));
            }

            void turn(char &ch)
            {
                 
            if (ch=='w') ch='b';
                 
            else ch='w';
            }

            void bfs()
            {
                 
            while (!list.empty())
                 
            {
                  
            string str=list.front();

                  
            int ti=list_t.front();
                  list.pop();
                  list_t.pop();
                  
            for (int i=0;i<16;i++)
                  
            {
                      
            string s=str;

                      
            int x;
                      
            //up
                      turn(s[i]);
                      x
            =i-4;
                      
            if (i>=0) turn(s[x]);
                      
            //down
                      x=i+4;
                      
            if (i<16) turn(s[x]);
                      
            //left
                      if (i%4!=0{x=i-1;turn(s[x]);}
                      
            //right
                      if (i%4!=3{x=i+1;turn(s[x]);}
                      
                      map
            <string,int>::iterator iter=hash.find(s);
                      
            if (iter==hash.end())
                      
            {
                       list.push(s);
                       list_t.push(ti
            +1);


                       
            if (s=="bbbbbbbbbbbbbbbb"||s=="wwwwwwwwwwwwwwww")
                       
            {
                        cout
            <<ti+1<<endl;
                        exit(
            0);
                        
                       }
             
                       hash.insert(map
            <string,int>::value_type(s,ti+1));
                      }

                    
                  }

                 }

                 cout
            <<"Impossible"<<endl;
            }


            int main()
            {
                init();
                bfs();
                
            return 0;
            }

            posted on 2009-10-01 14:32 Vincent 閱讀(245) 評論(0)  編輯 收藏 引用 所屬分類: 數(shù)據(jù)結(jié)構(gòu)與算法

            久久亚洲中文字幕精品一区四 | 久久这里有精品视频| 精品久久亚洲中文无码| 色综合合久久天天给综看| 久久精品国产99久久无毒不卡| 日本福利片国产午夜久久| 大伊人青草狠狠久久| av午夜福利一片免费看久久| 日产精品99久久久久久| 久久久久久国产精品免费无码 | 久久婷婷激情综合色综合俺也去| 国产精品久久久久久久人人看| 日本WV一本一道久久香蕉| 亚洲日韩中文无码久久| 日韩精品久久无码中文字幕| 国产精品女同久久久久电影院| 1000部精品久久久久久久久| 久久被窝电影亚洲爽爽爽| 精品久久久久久无码中文字幕 | 热久久最新网站获取| 久久综合亚洲欧美成人| 久久综合九色综合精品| 久久无码人妻精品一区二区三区| 狠狠色丁香婷婷久久综合| 久久精品国产第一区二区三区| 青青草原1769久久免费播放| 亚洲AⅤ优女AV综合久久久| 嫩草伊人久久精品少妇AV| 久久精品国产亚洲一区二区| 婷婷久久综合九色综合绿巨人| 久久综合亚洲欧美成人| 欧洲性大片xxxxx久久久| 人妻无码久久一区二区三区免费 | 99久久精品国产一区二区| 国产精品久久久久久久人人看| 精品久久久久久综合日本| 免费无码国产欧美久久18| 日韩一区二区久久久久久| 久久亚洲国产成人精品性色| 久久精品18| 99久久免费国产精品|