• <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打戰
            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)//只能斜向移動一個
                    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)//只能斜向移動兩個
                    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))))//只能在這幾個位子
                    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)//吃子中間要有一個,移動的話中間沒有
                        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打戰
            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ǎ崽 閱讀(445) 評論(0)  編輯 收藏 引用
            久久精品午夜一区二区福利| 无码人妻久久一区二区三区 | 久久精品国产精品亚洲下载| 色婷婷久久久SWAG精品| 久久久久99精品成人片欧美| 人妻丰满AV无码久久不卡| 久久久WWW成人| 亚洲午夜久久久久妓女影院| 久久久久国产一区二区| 亚洲午夜久久久影院| 伊人久久大香线蕉影院95| 人妻精品久久久久中文字幕69| 996久久国产精品线观看| 人妻久久久一区二区三区| 青青青青久久精品国产h| 精品一区二区久久久久久久网站| 伊人色综合久久天天人手人婷| …久久精品99久久香蕉国产| 久久久久一级精品亚洲国产成人综合AV区 | 中文国产成人精品久久不卡| 国产成人精品久久亚洲高清不卡 | 精品熟女少妇a∨免费久久| 新狼窝色AV性久久久久久| 精品无码久久久久久久动漫| 国产成人无码精品久久久免费| 精品久久人人爽天天玩人人妻| 欧美激情一区二区久久久| 久久久久久久免费视频| 久久久噜噜噜久久中文字幕色伊伊| 久久久久久免费一区二区三区| 亚洲国产精品成人久久| 亚洲精品无码久久毛片| 亚洲中文久久精品无码ww16| 久久久久亚洲AV无码专区桃色| 久久精品成人免费看| 一本一道久久综合狠狠老| 久久中文字幕人妻丝袜| 久久热这里只有精品在线观看| 国产精品成人久久久| 久久久久人妻一区二区三区| 久久人做人爽一区二区三区|