• <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>
            隨筆-72  評論-126  文章-0  trackbacks-0
            http://acm.hdu.edu.cn/showproblem.php?pid=2678     Dota打怪
            http://acm.hdu.edu.cn/showproblem.php?pid=1107     模擬RPG打戰(zhàn)
            http://acm.hdu.edu.cn/showproblem.php?pid=2414     棋盤棋子移動
            http://acm.hdu.edu.cn/showproblem.php?pid=2258     連連游戲
            http://acm.hdu.edu.cn/showproblem.php?pid=2240     飛行棋


            http://acm.hdu.edu.cn/showproblem.php?pid=1691
               下象棋
            要考慮好多好多東西阿

            #include<stdio.h>
            #include
            <stdlib.h>

            int map[11][11];
            int kingx,kingy;


            bool see()//能見到對方的王
            {
                
            int i;
                
            for(i=kingx-1;i>=0;i--)
                    
            if(map[i][kingy])
                        
            break;
                
            if(i==-1 || map[i][kingy]!=8)
                    
            return false;
                
            return true;
            }


            bool King(int a,int b,int c,int d)
            {
                
            int dis;
                dis 
            = abs(a-c) + abs(b-d);
                
            if(dis!=1)
                    
            return false;//只能一動一格


                
            if(map[a][b]==8 && (d<4 || d>6 || c<1 || c>3))
                    
            return false;
                
            if(map[a][b]==1 && (d<4 || d>6 || c<8 || c>10))
                    
            return false;//不能移出九宮格


                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(map[c][d]==1)
                {
                    kingx 
            = c;
                    kingy 
            = d;
                }
                
            if(see())
                    
            return false;
                
            return true;
            }


            bool Mandarin(int a,int b,int c,int d)
            {
                
            int disa,disb;
                disa 
            = abs(a-c);
                disb 
            = abs(b-d);
                
            if(disa!=1 || disb!=1)//只能斜向移動一個(gè)
                    return false;
                
            if(map[a][b]==9 && (d<4 || d>6 || c<1 || c>3))
                    
            return false;
                
            if(map[a][b]==2 && (d<4 || d>6 || c<8 || c>10))//只能在九宮格
                    return false;
                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(see())
                    
            return false;
                
            return true;
            }


            bool Elephant(int a,int b,int c,int d)
            {
                
            int disa,disb,x,y;
                disa 
            = abs(a-c);
                disb 
            = abs(b-d);
                
            if(disa!=2 || disb!=2)//只能斜向移動兩個(gè)
                    return false;
                
            if(map[a][b]==10 && !(((c==1 || c==5)&& (d==3 || d==7)) || (c==3 && (d==1 || d==5 || d==9))))
                    
            return false;
                
            if(map[a][b]==3 && !(((c==6 || c==10)&& (d==3 || d==7)) || (c==8 && (d==1 || d==5 || d==9))))//只能在這幾個(gè)位子
                    return false;
                x 
            = (a+c)/2;
                y 
            = (b+d)/2;
                
            if(map[x][y])
                    
            return false;//象腳
                map[c][d] = map[a][b];
                map[a][b] 
            = 0;
                
            if(see())
                    
            return false;
                
            return true;
            }


            bool Knight(int a,int b,int c,int d)
            {
                
            int dir[][2]={{1,2},{1,-2},{-1,2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1}};
                
            int majiao[][2]={{0,1},{0,-1},{0,1},{0,-1},{1,0},{1,0},{-1,0},{-1,0}};
                
            int i;
                
            for(i=0;i<8;i++)
                {
                    
            if(a+dir[i][0]==&& b+dir[i][1]==d)
                    {
                        
            if(map[ a+majiao[i][0] ][ b+majiao[i][1] ])//馬腳
                            return false;
                        
            break;
                    }
                }
                
            if(i==8)
                    
            return false;
                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(see())
                    
            return false;
                
            return true;
            }


            bool Rook(int a,int b,int c,int d)
            {
                
            int i;
                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(a==c)//橫向移動
                {
                    
            if(b>d)
                        b
            ^=d^=b^=d;
                    
            for(i=b+1;i<d;i++)
                        
            if(map[a][i])//中間不能有其他棋子
                            break;
                    
            if(i!=d)
                        
            return false;
                    
            if(see())
                        
            return false;
                    
            return true;
                }
                
            else if(b==d)
                {
                    
            if(a>c)
                        a
            ^=c^=a^=c;
                    
            for(i=a+1;i<c;i++)
                        
            if(map[i][b])
                            
            break;
                    
            if(i!=c)
                        
            return false;
                    
            if(see())
                        
            return false;
                    
            return true;
                }
                
            else
                    
            return false;
            }


            bool Cannons(int a,int b,int c,int d)
            {
                
            int i,cnt=0;
                
            int k = map[c][d];
                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(a==c)
                {
                    
            if(b>d)
                        b
            ^=d^=b^=d;
                    
            for(i=b+1;i<d;i++)
                        
            if(map[a][i])
                            cnt 
            ++;
                    
            if(k==0 && cnt || k && cnt!=1)//吃子中間要有一個(gè),移動的話中間沒有
                        return false;
                    
            if(see())
                        
            return false;
                    
            return true;
                }
                
            else if(b==d)
                {
                    
            if(a>c)
                        a
            ^=c^=a^=c;
                    
            for(i=a+1;i<c;i++)
                        
            if(map[i][b])
                            cnt 
            ++;
                    
            if(k==0 &&cnt || k && cnt!=1)
                        
            return false;
                    
            if(see())
                        
            return false;
                    
            return true;
                }
                
            else
                    
            return false;
            }


            bool Pawns(int a,int b,int c,int d)
            {
                
            int dis;
                dis 
            = abs(a-c) + abs(b-d);
                
            if(dis!=1)
                    
            return false;
                
            int k = map[a][b];
                map[c][d] 
            = map[a][b];
                map[a][b] 
            = 0;
                
            if(k==14)
                {
                    
            if(a<6 && (a>|| d!=b) || a>c)//過河前不能左右移動,且不能退后
                        return false;
                }
                
            else
                {
                    
            if(a>5 && (a<|| b!=d) || a<c)
                        
            return false;
                }
                
            if(see())
                    
            return false;
                
            return true;
            }


            bool move(int a,int b,int c,int d,int turn)
            {
                
            if(map[a][b]<=turn*7 || map[a][b]>turn*7+7)
                    
            return false;
                
            if(map[a][b]==1 || map[a][b]==8)
                    
            return King(a,b,c,d);
                
            else if(map[a][b]==2 || map[a][b]==9)
                    
            return Mandarin(a,b,c,d);
                
            else if(map[a][b]==3 || map[a][b]==10)
                    
            return Elephant(a,b,c,d);
                
            else if(map[a][b]==4 || map[a][b]==11)
                    
            return Knight(a,b,c,d);
                
            else if(map[a][b]==5 || map[a][b]==12)
                    
            return Rook(a,b,c,d);
                
            else if(map[a][b]==6 || map[a][b]==13)
                    
            return Cannons(a,b,c,d);
                
            else
                    
            return Pawns(a,b,c,d);
            }


            bool same(int x,int y)//吃到自己的棋子
            {
                
            if(x==0)
                    
            return false;
                
            if(y==0)
                    
            return true;
                
            if(0<x&&x<8&&0<y&&y<8 || 7<x&&x<15&&7<y&&y<15)
                    
            return false;
                
            return true;
            }


            int main()
            {
                
            int T,n,i,j,turn,ill,K=1;
                scanf(
            "%d",&T);
                
            while(T--)
                {
                    
            for(i=1;i<=10;i++)
                        
            for(j=1;j<=9;j++)
                        {
                            scanf(
            "%d",&map[i][j]);
                            
            if(map[i][j]==1)
                            {
                                kingx 
            = i;
                                kingy 
            = j;
                            }
                        }
                    scanf(
            "%d%d",&n,&turn);//1 big      0 small
                    ill = 0;
                    
            for(i=1;i<=n;i++)
                    {
                        
            int a,b,c,d;
                        scanf(
            "%d%d%d%d",&a,&b,&c,&d);
                        
            if(!ill)
                        {
                            
            if(a<=0 || a>10 || c<=0 || c>10 || b<=0 || b>9 || d<=0 || d>9)//出界
                                ill = i;
                            
            if(i!=&& (map[c][d]==1 || map[c][d]==8))//吃王
                                ill = i+1;
                            
            if(!same(map[a][b],map[c][d]) || !move(a,b,c,d,turn))//吃到自己棋子        非法移動
                                ill = i;
                            turn 
            ^= 1;
                        }
                    }
                    printf(
            "Case %d: ",K++);
                    
            if(ill)
                        printf(
            "Illegal move on step %d\n",ill);
                    
            else
                        puts(
            "Legal move");
                }
                
            return 0;
            }



            http://acm.hdu.edu.cn/showproblem.php?pid=2678     Dota打怪
            http://acm.hdu.edu.cn/showproblem.php?pid=1107     模擬RPG打戰(zhàn)
            http://acm.hdu.edu.cn/showproblem.php?pid=2414     棋盤棋子移動
            http://acm.hdu.edu.cn/showproblem.php?pid=2258     連連游戲
            http://acm.hdu.edu.cn/showproblem.php?pid=2240     飛行棋
            posted on 2009-03-19 14:18 shǎ崽 閱讀(451) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久亚洲春色中文字幕久久久 | 免费精品99久久国产综合精品| 亚洲国产精品无码久久久蜜芽 | 国产成人精品久久亚洲高清不卡| 国产亚洲精午夜久久久久久| 久久久无码精品亚洲日韩京东传媒| 人妻精品久久无码专区精东影业| 久久精品草草草| 狠狠色综合网站久久久久久久高清| 亚洲国产天堂久久综合网站| 精品综合久久久久久97| 精品视频久久久久| 久久这里只有精品18| 无码国内精品久久人妻麻豆按摩| 国产V综合V亚洲欧美久久| 最新久久免费视频| 久久精品三级视频| 伊人热人久久中文字幕| 久久精品国产亚洲精品2020| 久久精品国产亚洲AV香蕉| 久久99亚洲综合精品首页| 久久成人国产精品二三区| 国内精品久久久久影院薰衣草| 亚洲欧美国产日韩综合久久| www亚洲欲色成人久久精品| jizzjizz国产精品久久| 一本久道久久综合狠狠爱| 久久伊人中文无码| 久久久久久国产精品免费免费| 一本一道久久精品综合| 国产精品久久久久9999| 东京热TOKYO综合久久精品| 久久久一本精品99久久精品88 | 久久人人爽人人爽人人片av高请| 青青青青久久精品国产h久久精品五福影院1421| 国产精品国色综合久久| 99精品国产99久久久久久97 | 久久AV无码精品人妻糸列| av色综合久久天堂av色综合在| 亚洲午夜久久久| 久久久午夜精品福利内容|