• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            經典搜索問題。
            以下是我的代碼:
            /*
             * Author:  lee1r
             * Created Time:  2011/8/6 7:47:26
             * File Name: poj2488.cpp
             
            */
            #include
            <iostream>
            #include
            <sstream>
            #include
            <fstream>
            #include
            <vector>
            #include
            <list>
            #include
            <deque>
            #include
            <queue>
            #include
            <stack>
            #include
            <map>
            #include
            <set>
            #include
            <bitset>
            #include
            <algorithm>
            #include
            <cstdio>
            #include
            <cstdlib>
            #include
            <cstring>
            #include
            <cctype>
            #include
            <cmath>
            #include
            <ctime>
            #define L(x) ((x)<<1)
            #define R(x) (((x)<<1)+1)
            #define Half(x) ((x)>>1)
            #define lowbit(x) ((x)&(-(x)))
            using namespace std;
            const int kInf(0x7f7f7f7f);
            const double kEps(1e-8);
            typedef 
            long long int64;
            typedef unsigned 
            long long uint64;

            const int kMaxn(27);
            const int dx[]={-2,-2,-1,1,2,2,1,-1},dy[]={-1,1,2,2,1,-1,-2,-2};

            int n,m;
            string ans,d;
            bool used[kMaxn][kMaxn];

            string itoa(int x)
            {
                
            string re,t;
                
            while(x>0)
                {
                    t
            +=(x%10+'0');
                    x
            /=10;
                }
                
            for(int i=t.size()-1;i>=0;i--)
                    re
            +=t[i];
                
            return re;
            }

            void erase(string &t)
            {
                
            int pos;
                
            for(pos=t.size()-1;pos>=0;pos--)
                    
            if(isalpha(t[pos]))
                        
            break;
                t.erase(pos,t.size()
            -pos);
            }

            void dfs(int depth,int x,int y)
            {
                
            if(ans<=d)
                    
            return;
                
            if(depth>n*m)
                {
                    ans
            =d;
                    
            return;
                }
                
            for(int i=0;i<8;i++)
                {
                    
            int newx(x+dx[i]),newy(y+dy[i]);
                    
            if(newx<1 || newx>|| newy<1 || newy>|| used[newx][newy])
                        
            continue;
                    d
            +=(char)(newx+'A'-1);
                    d
            +=itoa(newy);
                    used[newx][newy]
            =true;
                    dfs(depth
            +1,newx,newy);
                    erase(d);
                    used[newx][newy]
            =false;
                }
            }

            int main()
            {
                
            //freopen("data.in","r",stdin);
                
                
            int T;
                scanf(
            "%d",&T);
                
            for(int case_num=1;case_num<=T;case_num++)
                {
                    scanf(
            "%d%d",&m,&n);
                    ans
            ="z";
                    
            for(int i=1;i<=min(Half(n)+1,n);i++)
                        
            for(int j=1;j<=min(Half(m)+1,m);j++)
                        {
                            d
            +=(char)(i+'A'-1);
                            d
            +=itoa(j);
                            used[i][j]
            =true;
                            dfs(
            2,i,j);
                            erase(d);
                            used[i][j]
            =false;
                        }
                    
                    printf(
            "Scenario #%d:\n",case_num);
                    
            if(ans<"z")
                        cout
            <<ans<<endl;
                    
            else
                        cout
            <<"impossible"<<endl;
                    cout
            <<endl;
                }
                
                
            return 0;
            }
            posted on 2011-08-06 08:25 lee1r 閱讀(205) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:搜索
            国产精品99久久久久久人| 欧美精品乱码99久久蜜桃| 色偷偷偷久久伊人大杳蕉| 99久久免费国产精精品| 久久一本综合| 久久精品一区二区| 国内精品伊人久久久久777| 2021久久国自产拍精品| 午夜精品久久影院蜜桃| 9久久9久久精品| 欧美久久久久久| 狠狠色综合久久久久尤物| 久久精品人成免费| 无码精品久久一区二区三区 | 久久精品国产亚洲av高清漫画| 久久中文娱乐网| 久久精品国产亚洲AV不卡| 日韩中文久久| 99久久99久久精品国产片| a高清免费毛片久久| 久久永久免费人妻精品下载| 中文字幕无码久久人妻| 精品免费久久久久国产一区| 久久99国产精品二区不卡| 奇米综合四色77777久久| 久久久这里有精品| 日韩电影久久久被窝网| 久久久久久亚洲精品无码| 日本精品久久久久中文字幕8| 国内精品九九久久久精品| 精品国产乱码久久久久久人妻| 亚洲精品久久久www| 日本高清无卡码一区二区久久| 久久最新免费视频| 人妻少妇精品久久| 亚洲七七久久精品中文国产| 无码乱码观看精品久久| 久久久精品国产免大香伊| 狠狠色婷婷久久一区二区| 久久无码人妻一区二区三区 | 色诱久久av|