刘汝佳紫书 uva220 解题报告

没想到AC了好感动啊。。。

前面的那道象棋蜜汁WA把我搞的身心俱疲,又见到一个和棋有关的题就怂了啊

本来觉得会和象棋那题一样蜜汁WA的说,结果提交的时候看到presentation error整个心是紧了一下好吗!!简直是初恋的感觉啊!!

我的做法是把棋盘上的每个点都定义两个值来判断是否为黑子或者白子可落点,然后每个可落点都有一系列关联点,用于之后落子时将改点和关联点之间的棋子全部覆盖为同色。



结果这题输出及其坑爹。。。

输出注意:

1、打印有效点的时候每个点之间都有空格,但是最后一个点后面不能有

2、每个回合之间有空行(这个想必大家都会注意到)

3、输出黑白棋子各自剩余多少时,应该按照Black - xx White - yy这样的格式输出,就是要注意输出长度

自己没有仔细看题的习惯呢。。


下面是代码,那些用5000bytes就能解决的人好厉害啊。。。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct point{
    int r;
    int c;
};
struct unit{
    bool b_legal,w_legal;
    point correlation[1000];
    int c_n;
    int type;//1:black 2:white
};
unit bot[15][15];
void up(int type,int r,int c){
    int t=r-1;
    if(r-1>=1){
        r--;
        while(bot[r][c].type==type){
            r--;
        }
        if(t!=r){
            if(type==1){bot[r][c].w_legal=1;}else{bot[r][c].b_legal=1;}
            bot[r][c].correlation[bot[r][c].c_n].r=t+1;
            bot[r][c].correlation[bot[r][c].c_n].c=c;
            bot[r][c].c_n++;
        }
    }
}
void down(int type,int r,int c){
    int t=r+1;
    if(r+1<9){
        r++;
        while(bot[r][c].type==type){
            r++;
        }
        if(t!=r){
            if(type==1){bot[r][c].w_legal=1;}else{bot[r][c].b_legal=1;}
            bot[r][c].correlation[bot[r][c].c_n].r=t-1;
            bot[r][c].correlation[bot[r][c].c_n].c=c;
            bot[r][c].c_n++;
        }
    }
}
void left(int type,int r,int c){
    int t=c-1;
    if(c-1>=1){
        c--;
        while(bot[r][c].type==type){
            c--;
        }
        if(t!=c){
            if(type==1){bot[r][c].w_legal=1;}else{bot[r][c].b_legal=1;}
            bot[r][c].correlation[bot[r][c].c_n].r=r;
            bot[r][c].correlation[bot[r][c].c_n].c=t+1;
            bot[r][c].c_n++;
        }
    }
}
void right(int type,int r,int c){
    int t=c+1;
    if(c+1<9){
        c++;
        while(bot[r][c].type==type){
            c++;
        }
        if(t!=c){
            if(type==1){bot[r][c].w_legal=1;}else{bot[r][c].b_legal=1;}
            bot[r]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值