//UVa1589 - Xiangqi
//WA
#include<iostream>
#include<string.h>
using namespace std;
typedef struct XYZ{
char name;
int x,y;
XYZ(int x = 0, int y = 0):x(x),y(y){};
};
int qp[11][10];//qipan
char sq[11][10];//shaqi
XYZ RQ[8];//red qi
void G(int x, int y);//jiang
void R(int x, int y);//che
void H(int x, int y);//ma
void C(int x, int y);//pao
int BGgoing(int x, int y);
int main(){
int RT;//red qi number
XYZ BG;//black G
while(cin>>RT>>BG.x>>BG.y){
//��ʼ��������
memset(qp,0,sizeof(qp));
memset(sq,'A',sizeof(sq));
//��¼����
for(int i = 1; i <= RT; i++){
cin>>RQ[i].name>>RQ[i].x>>RQ[i].y;
qp[RQ[i].x][RQ[i].y] = (int)RQ[i].name;
}
//doing
for(int i = 1; i <= RT; i++){
if(RQ[i].name == 'G') G(RQ[i].x,RQ[i].y);
if(RQ[i].name == 'R') R(RQ[i].x,RQ[i].y);
if(RQ[i].name == 'H') H(RQ[i].x,RQ[i].y);
if(RQ[i].name == 'C') C(RQ[i].x,RQ[i].y);
}
//ans out
if(BGgoing(BG.x, BG.y)) cout<<"YES\n";
else cout<<"NO\n";
//qp out
for(int i = 1; i <= 10; i++){
for(int j = 1; j <= 9; j++)
cout<<qp[i][j]<<" ";
cout<<"\n";
}
continue;
}
return 0;
}
void G(int x, int y){
for(int i = 1; i <= 10; i++)
if(qp[i][y] != 0 && qp[i][y] != (int)'G')return ;
for(int i = 1; i <= 10; i++)
sq[i][y] = 'S';
}
void R(int x, int y){
for(int i = x-1; i >= 1; i--){
if(qp[i][y] == 0) sq[i][y] = 'S';
else break;
}
for(int i = x+1; i <= 10; i++){
if(qp[i][y] == 0) sq[i][y] = 'S';
else break;
}
for(int i = y-1; i >= 1; i--){
if(qp[x][i] == 0) sq[x][i] = 'S';
else break;
}
for(int i = y+1; i <= 9; i++){
if(qp[x][i] == 0) sq[x][i] = 'S';
else break;
}
return ;
}
void H(int x, int y){
if(qp[x-1][y] == 0) sq[x-2][y+1] = 'S', sq[x-2][y-1] = 'S';
if(qp[x+1][y] == 0) sq[x+2][y+1] = 'S', sq[x+2][y-1] = 'S';
if(qp[x][y-1] == 0) sq[x+1][y-2] = 'S', sq[x-1][y-2] = 'S';
if(qp[x][y+1] == 0) sq[x+1][y+2] = 'S', sq[x-1][y+2] = 'S';
return ;
}
void C(int x, int y){
int is = 0;
for(int i = x-1; i >= 1; i--){
if(qp[i][y] != 0) {is++; continue;}
if(is == 1) sq[i][y] = 'S';
else if(is == 2){ sq[i][y] = 'S'; break;}
}
is = 0;
for(int i = x+1; i <= 10; i++){
if(qp[i][y] != 0) {is++; continue;}
if(is == 1) sq[i][y] = 'S';
else if(is == 2){ sq[i][y] = 'S'; break;}
}
is = 0;
for(int i = y-1; i >= 1; i--){
if(qp[x][i] != 0) {is++; continue;}
if(is == 1) sq[x][i] = 'S';
else if(is == 2){ sq[x][i] = 'S'; break;}
}
is = 0;
for(int i = y+1; i <= 9; i++){
if(qp[x][i] != 0) {is++; continue;}
if(is == 1) sq[x][i] = 'S';
else if(is == 2){ sq[x][i] = 'S'; break;}
}
return ;
}
int BGgoing(int x, int y){
int iss = 0;
if(x-1>=1 && x-1<=3 && sq[x-1][y]=='S') iss++;
if(x+1>=1 && x+1<=3 && sq[x+1][y]=='S') iss++;
if(y-1>=4 && y-1<=6 && sq[x][y-1]=='S') iss++;
if(y+1>=4 && y+1<=6 && sq[x][y+1]=='S') iss++;
if(iss) return 1;
else return 0;
}
UVa1589 - Xiangqi
原创
©著作权归作者所有:来自51CTO博客作者小哈里1139的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
UVA 1589 Xiangqi——模拟
模拟题,我的做法是先让黑将分别上下左右移动,对每一种情况 先判断是否能被马将
uva #include i++ -
4-1 UVA 1589Xiangqi中国象棋
这个题,写完很久了,一直没发没记录,今天补上。这个题自己真#include#define MAX 15#includeconst int dx[] = {0
c语言 uva i++ #include #define -
NOJ1589——[1589] 老蔡和TT
少要造的路吗?输入第一行包含2个整数,n,m (0接下来的m行,每行2个整数a和b,
图的连通性 #include Stack i++ -
1589: 奖学金 (结构体)
1589: 奖学金时间限制: 1 Sec 内存限制: 128 MB提交: 44 解决: 28[提交][状态][讨论版]题
#include i++ #define -
BZOJ 1589 采集糖果
23333怎么调了一晚上。。。。
#include i++ #define ios BZOJ