• <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
            經(jīng)典搜索問題。
            以下是我的代碼:
            /*
             * 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 閱讀(212) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:搜索
            国产精品久久一区二区三区| 少妇久久久久久被弄到高潮| 久久精品国产99久久久| 久久国产精品无码一区二区三区| 日产精品久久久久久久性色| 99re久久精品国产首页2020| 久久最新免费视频| 久久精品亚洲精品国产色婷| 久久免费视频一区| 国内精品久久久久久久97牛牛| 久久99精品九九九久久婷婷| 人人狠狠综合久久88成人| 久久精品国产精品亚洲| 97久久久久人妻精品专区| 久久久精品波多野结衣| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 狠狠色丁香久久婷婷综合蜜芽五月| 久久久亚洲裙底偷窥综合| 94久久国产乱子伦精品免费| 漂亮人妻被中出中文字幕久久| 久久夜色精品国产亚洲| 亚洲国产精品无码久久| 一本色道久久88综合日韩精品| 国产午夜福利精品久久| 久久91综合国产91久久精品| 日本人妻丰满熟妇久久久久久 | 99精品久久精品一区二区| 99久久99久久精品国产片| 国产成人精品久久二区二区| 少妇内射兰兰久久| 无码日韩人妻精品久久蜜桃| 久久国产劲爆AV内射—百度| 合区精品久久久中文字幕一区| 久久人妻少妇嫩草AV无码蜜桃| 丁香久久婷婷国产午夜视频| 久久久青草久久久青草| 久久香蕉综合色一综合色88| 国产福利电影一区二区三区,免费久久久久久久精 | 久久精品国产亚洲AV香蕉| 久久无码国产| 国内精品伊人久久久久妇|