• <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上找到了數據
               測試數據正確
               于是懷疑是我用<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 閱讀(247) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            久久伊人中文无码| 久久99国产综合精品女同| 久久夜色精品国产欧美乱| 91精品国产乱码久久久久久| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久精品中文字幕第23页| 久久影院综合精品| 国产精品免费久久| 久久se精品一区二区| 国产成年无码久久久免费| 91精品国产色综久久 | 久久中文字幕视频、最近更新| 狠狠色丁香久久婷婷综合_中 | 亚洲国产欧洲综合997久久| 国产精品欧美亚洲韩国日本久久| 亚洲综合久久久| 日本久久中文字幕| 国产精品免费看久久久香蕉| 亚洲国产欧美国产综合久久| 久久天天日天天操综合伊人av| 久久er热视频在这里精品| 久久精品国产日本波多野结衣| yy6080久久| 久久国产免费| 91久久成人免费| 久久美女网站免费| 久久露脸国产精品| 国产成人精品综合久久久| 青青青国产精品国产精品久久久久| 精品无码久久久久国产动漫3d| 一级a性色生活片久久无| 亚洲精品综合久久| 国产高清美女一级a毛片久久w | 久久久久亚洲AV综合波多野结衣| 久久国产精品一区二区| 青青国产成人久久91网| 久久精品国产亚洲网站| 成人国内精品久久久久影院VR| 久久99国产精品成人欧美| 欧美日韩精品久久久久 | 精品久久久无码中文字幕天天|