#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int n,x,y,a,b;
char qipan[15][15];
int is_shuai(){
int flag = 0;
for(int i = a+1; i <= 10; i++){
if(qipan[i][b] != 'O'&&qipan[i][b]!='G'){
break;
}
if(qipan[i][b] == 'G'){
flag = 1;
break;
}
}
return flag;
}
int is_ju(){
int flag = 0;
for(int i = a+1; i <= 10; i++){
if(qipan[i][b] != 'O'&&qipan[i][b]!='R'){
break;
}
if(qipan[i][b] == 'R'){
flag = 1;
break;
}
}
if(!flag){
for(int i = a-1; i >= 1; i--){
if(qipan[i][b] != 'O'&&qipan[i][b]!='R'){
break;
}
if(qipan[i][b] == 'R'){
flag = 1;
break;
}
}
}
if(!flag){
for(int i = b+1; i <= 9; i++){
if(qipan[a][i] != 'O'&&qipan[a][i]!='R'){
break;
}
if(qipan[a][i] == 'R'){
flag = 1;
break;
}
}
}
if(!flag){
for(int i = b-1; i >= 1; i--){
if(qipan[a][i] != 'O'&&qipan[a][i]!='R'){
break;
}
if(qipan[a][i] == 'R'){
flag = 1;
break;
}
}
}
return flag;
}
int is_pao(){
int flag = 0;
int cnt = 0;
for(int i = a+1; i <= 10; i++){
if(qipan[i][b] != 'O'&&qipan[i][b]!='C'){
cnt++;
}
if(qipan[i][b] == 'C'){
cnt++;
if(cnt == 2) flag = 1;
}
}
if(!flag){
cnt = 0;
for(int i = a-1; i >= 1; i--){
if(qipan[i][b] != 'O'&&qipan[i][b]!='C'){
cnt++;
}
if(qipan[i][b] == 'C'){
cnt++;
if(cnt == 2) flag = 1;
}
}
}
if(!flag){
cnt = 0;
for(int i = b+1; i <= 9; i++){
if(qipan[i][b] != 'O'&&qipan[i][b]!='C'){
cnt++;
}
if(qipan[i][b] == 'C'){
cnt++;
if(cnt == 2) flag = 1;
}
}
}
if(!flag){
cnt = 0;
for(int i = b-1; i >= 1; i--){
if(qipan[i][b] != 'O'&&qipan[i][b]!='C'){
cnt++;
}
if(qipan[i][b] == 'C'){
cnt++;
if(cnt == 2) flag = 1;
}
}
}
return flag;
}
int is_ma(){
int flag = 0;
if(a-2>=1){
if(qipan[a-2][b-1] == 'H'&&qipan[a-1][b-1] == 'O') flag = 1;
if(qipan[a-2][b+1] == 'H'&&qipan[a-1][b+1] == 'O') flag = 1;
}
if(!flag && a-1>=1){
if(qipan[a-1][b-2] == 'H'&&qipan[a-1][b-1] == 'O') flag = 1;
if(qipan[a-1][b+2] == 'H'&&qipan[a-1][b+1] == 'O') flag = 1;
}
if(qipan[a+2][b-1] == 'H'&&qipan[a+1][b-1] == 'O') flag = 1;
if(qipan[a+1][b-2] == 'H'&&qipan[a+1][b-1] == 'O') flag = 1;
if(qipan[a+2][b+1] == 'H'&&qipan[a+1][b+1] == 'O') flag = 1;
if(qipan[a+1][b+2] == 'H'&&qipan[a+1][b+1] == 'O') flag = 1;
return flag;
}
int go(){
int flag = 1;
if(a<1||a>3||b<4||b>6) return 1;
if(is_shuai()) return 1;
if(is_ju()) return 1;
if(is_pao()) return 1;
if(is_ma()) return 1;
return -1;
}
int main(){
while( scanf("%d%d%d", &n,&a,&b) == 3){
if(n == 0) break;
memset(qipan, 'O', sizeof(qipan));
while(n--){
char ch;
cin>>ch;
scanf("%d%d", &x, &y);
qipan[x][y] = ch;
}
int flag = 0;
char t;
if(is_shuai()) flag = -1;
if(flag == 0){
b--; t = qipan[a][b]; qipan[a][b] = 'O'; if(go() == 1) flag=1; qipan[a][b] = t; b++;
}
if(flag == 1){
b++; t = qipan[a][b]; qipan[a][b] = 'O'; if(go() == 1) flag++; qipan[a][b] = t; b--;
}
if(flag == 2){
a++; t = qipan[a][b]; qipan[a][b] = 'O'; if(go() == 1) flag++; qipan[a][b] = t; a--;
}
if(flag == 3){
a--; t = qipan[a][b]; qipan[a][b] = 'O'; if(go() == 1) flag++; qipan[a][b] = t; a++;
}
if(flag == 4){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}
习题4-1 象棋
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 2018.2.3 目标:身心健康,财富丰盛 好种子: 1早起健康早餐,种下健康的种子,回向群里姐妹及家人身心健康 ...