• <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>
            #include <iostream>
            #include 
            <queue>

            using namespace std;

            bool  g[4][4];
            int   binary[16]= 124816326412825651210242048409681921638432768 };
            bool  visited[65538];

            int change( bool gg[4][4] )
            {
             
            int num= 0;
             
            int t= 15;
             
             
            for ( int i= 0; i< 4++i )
                
            for ( int j= 0; j< 4++j )
                 
            {
               
            if ( gg[i][j] ) num+= binary[t];
               
               t
            --;
              }

              
             
            return num;  
            }


            void recover( int data, bool temp[4][4] )
            {
             
            int  re[16];
             
            int  t= 15;
             
             memset( re, 
            0sizeof(re) );
             
            while ( data!= 0 )
             
            {
              re[t]
            = ( data% 2 );
              
              data
            /= 2;
              t
            -- ;
             }

             t
            = 0;

             
            for ( int i= 0; i< 4++i )
                 
            for ( int j= 0; j< 4++j )
                 
            {
               temp[i][j]
            = ( re[t]== 1 );
               t
            ++;
              }
             
            }


            struct Node
            {
             
            int value;
             
            int steps;
             
             Node()
             
            {}
             
             Node( 
            int a, int b )
             :value(a), steps(b)
             
            {}
            }
            ;

            void copy( bool b1[4][4], bool b2[4][4] )
            {
             
            for ( int i= 0; i< 4++i )
               
            for ( int j= 0; j< 4++j )
                 b2[i][j]
            = b1[i][j];
            }


            void print( bool b[4][4] )
            {
             
            for ( int i= 0; i< 4++i )
             
            {
              
            for ( int j= 0; j< 4++j )
              cout 
            << b[i][j] << ' ';
              
              cout 
            << endl;
             }

            }


            int main()
            {
             
            for ( int i= 0; i< 4++i )
             
            {
                
            for ( int j= 0; j< 4++j )
                
            {
               
            char ch;
               scanf(
            "%c",&ch);
               
               g[i][j]
            = ( ch== 'b' );
              }

              
              getchar();
            }

             
             memset( visited, 
            falsesizeof(visited) ); 
             queue
            <Node> q;
             
             q.push( Node( change(g), 
            0 ) );
             visited[ change(g) ]
            = true;
             
            bool  ans= false;
             
             
            while ( !q.empty() )
             
            {
              
            bool  temp[4][4];
              Node  t
            = q.front();
              q.pop();
              
              
            if ( t.value== 0 || t.value== 65535 )
              
            {
               printf(
            "%d", t.steps );
               ans
            = true;
               
               
            break;
              }

              
              recover( t.value, temp );
              
              
            for ( int i= 0; i< 4++i )
                  
            for ( int j= 0; j< 4++j )
                  
            {
                
            bool  tt[4][4];
                copy( temp, tt );

                tt[i][j]
            = !tt[i][j];
                
            if ( i- 1>= 0 ) tt[i-1][j]= !tt[i-1][j];
                
            if ( i+ 1< 4 )  tt[i+1][j]= !tt[i+1][j];
                
            if ( j- 1>= 0 ) tt[i][j-1]= !tt[i][j-1];
                
            if ( j+ 1< 4 )  tt[i][j+1]= !tt[i][j+1];
                
                
            int   curr= change( tt );
                
                
            if ( !visited[curr] )
                
            {
                 q.push( Node( curr, t.steps
            + 1) );
                 visited[curr]
            = true;
                }

               }

             }

             
            if ( !ans ) printf("Impossible");

             
            return 0;
            }


            posted on 2008-11-06 12:40 Darren 閱讀(369) 評論(0)  編輯 收藏 引用
            一级女性全黄久久生活片免费| 伊人 久久 精品| 97久久超碰国产精品2021| 久久福利青草精品资源站免费| 99国内精品久久久久久久 | 国产精品无码久久久久久| 日韩一区二区久久久久久| 国产成人无码精品久久久性色| 美女写真久久影院| 丰满少妇人妻久久久久久| 一级女性全黄久久生活片免费| 免费观看久久精彩视频| 久久久精品人妻一区二区三区四| 久久影视综合亚洲| 久久精品国产69国产精品亚洲| 久久婷婷五月综合国产尤物app| 国产亚洲成人久久| 成人国内精品久久久久影院| 国产成人综合久久精品红| 国产无套内射久久久国产| 99久久国产综合精品麻豆| 无码人妻久久一区二区三区免费丨| 伊人久久大香线蕉综合热线| 99久久伊人精品综合观看| …久久精品99久久香蕉国产| 久久天天躁狠狠躁夜夜96流白浆| 久久久久久免费视频| 婷婷久久五月天| 亚洲综合久久久| 久久精品国产清自在天天线| 午夜精品久久久内射近拍高清 | 噜噜噜色噜噜噜久久| 久久免费视频一区| 久久综合亚洲色HEZYO国产| 久久人人爽人爽人人爽av | 欧美日韩精品久久久久| 久久亚洲2019中文字幕| 久久久久国产| 亚洲第一永久AV网站久久精品男人的天堂AV | 性做久久久久久久| 亚洲国产精品无码久久|