• <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ǎ崽 閱讀(446) 評論(0)  編輯 收藏 引用
            久久线看观看精品香蕉国产| 久久免费视频观看| 亚洲精品乱码久久久久久| 性高湖久久久久久久久| 国产产无码乱码精品久久鸭| 国产精品99久久久久久董美香 | 久久精品中文闷骚内射| 91久久精品国产免费直播| 亚洲国产成人久久综合一区77| 久久棈精品久久久久久噜噜| 久久福利片| 波多野结衣中文字幕久久| 一级女性全黄久久生活片免费| 99久久婷婷免费国产综合精品| 亚洲国产成人久久笫一页| 99久久精品免费| 久久久久久久久久久久中文字幕| 久久综合视频网站| 99久久er这里只有精品18| 一本久久精品一区二区| 91精品国产91久久| 国产精品99久久久久久人| 婷婷伊人久久大香线蕉AV| 麻豆av久久av盛宴av| 久久久久亚洲AV无码去区首| 久久se精品一区二区| 99久久超碰中文字幕伊人 | 好属妞这里只有精品久久| av色综合久久天堂av色综合在| 久久综合一区二区无码| 久久久免费观成人影院| 久久无码人妻精品一区二区三区 | 国产精品日韩深夜福利久久| 99久久无码一区人妻a黑| 亚洲精品乱码久久久久久蜜桃不卡| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久久久99精品成人片| 精品国产综合区久久久久久| 99久久精品国产毛片| 久久男人AV资源网站| 久久综合久久伊人|