模拟
#include <iostream>
#include <cstdio>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <climits>
using namespace std;
const int dx[5]={0,0,0,1,-1};
const int dy[5]={0,1,-1,0,0};
const int dhx[8]={1,2,2,1,-1,-2,-2,-1};
const int dhy[8]={-2,-1,1,2,2,1,-1,-2};
const int bx[8]={1,1,1,1,-1,-1,-1,-1};
const int by[8]={-1,-1,1,1,1,1,-1,-1};
int a[20][20];
int max4(int a,int b,int c,int d)
{
return max(max(a,b),max(c,d));
}
bool in(int x,int y)
{
return (x>0 && x<11 && y>0 && y<10);
}
bool in_g(int x,int y)
{
return ((y>3 && y<7 && x<4 && x>0)||(y>3 && y<7 && x<11 && x>7));
}
int main()
{
char ch;
int c,x0,y0,t1,t2,gx,gy;
//while (scanf("%d%d%d",&c,&x0,&y0)!=EOF && c && x0 && y0)
while (cin>>c>>x0>>y0 && c+x0+y0)
{
memset(a,-1,sizeof(a));
for (int i=0;i<c;i++)
{
cin>>ch>>t1>>t2;
//scanf("%s%d%d",ch,&t1,&t2);
if (ch=='G'){a[t1][t2]=0;gx=t1;gy=t2;}
else if (ch=='R') a[t1][t2]=1;
else if (ch=='H') a[t1][t2]=2;
else if (ch=='C') a[t1][t2]=3;
}
bool flag=true;
for (int i=1;i<5;i++)
{
bool ju=false;
int tx=x0+dx[i];
int ty=y0+dy[i];
if (!in_g(tx,ty)) continue;
for (int j=0;j<8;j++)
{
int hx=tx+dhx[j];
int hy=ty+dhy[j];
if (!in(hx,hy)) continue;
if (a[tx+bx[j]][ty+by[j]]==-1 && a[hx][hy]==2)
{
ju=true;
break;
}
}
if (ju) continue;
bool j1=false;
for (int j=1;j<=10-tx;j++)
{
if (a[tx+j][ty]!=-1)
{
if (!j1 && a[tx+j][ty]==1) {ju=true;break;}
else if (!j1 && a[tx+j][ty]!=-1) {j1=true;continue;}
if (j1 && a[tx+j][ty]==3) {ju=true;break;}
else if (j1 && a[tx+j][ty]!=-1) break;
}
}
if (ju) continue;
j1=false;
for (int j=1;j<=tx-1;j++)
{
if (a[tx-j][ty]!=-1)
{
if (!j1 && a[tx-j][ty]==1) {ju=true;break;}
else if (!j1 && a[tx-j][ty]!=-1){j1=true;continue;}
if (j1 && a[tx-j][ty]==3) {ju=true;break;}
else if (j1 && a[tx-j][ty]!=-1) break;
}
}
if (ju) continue;
j1=false;
for (int j=1;j<=9-ty;j++)
{
if (a[tx][ty+j]!=-1)
{
if (!j1 && a[tx][ty+j]==1) {ju=true;break;}
else if (!j1 && a[tx][ty+j]!=-1) {j1=true;continue;}
if (j1 && a[tx][ty+j]==3) {ju=true;break;}
else if (j1 && a[tx][ty+j]!=-1) break;
}
}
if (ju) continue;
j1=false;
for (int j=1;j<=ty-1;j++)
{
if (a[tx][ty-j]!=-1)
{
if (!j1 && a[tx][ty-j]==1) {ju=true;break;}
else if (!j1 && a[tx][ty-j]!=-1) {j1=true;continue;}
if (j1 && a[tx][ty-j]==3) {ju=true;break;}
else if (j1 && a[tx][ty-j]!=-1)break;
}
}
if (ju) continue;
bool j2;//false no zi
if (ty==gy)
{
j2=false;
for (int k=tx+1;k<gx;k++)
if (a[k][gy]!=-1) {j2=true;break;}
}
else j2=true;
if (!j2) ju=true;//can checkmate
if (ju==false) {flag=false;break;}
}
if (flag) cout<<"YES"<<endl;//printf("YES\n");
else cout<<"NO"<<endl;//printf("NO\n");
}
return 0;
}
分享到:
相关推荐
ruanjianceshi-fuzhou-ligong
chongwu-shangcheng-fuzhou-ligong
tushuguanli-xitong-fuzhou-ligong
zaixiangouwu-xitong-anzhuo-fuzhou-ligong
[Unknown]: fuzhou 您所在的省/市/自治区名称是什么? [Unknown]: fuzhou 该单位的双字母国家/地区代码是什么? [Unknown]: CN CN=chen, OU=ffcs, O=ffcs, L=fuzhou, ST=fuzhou, C=CN是否正确? [否]: y
福州大学电气学院2010级模电考试试卷,手抄版,仔细看还是看得清的。
Game Analysis on Competition in Industrial Cluster⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯Fuzhou LUO, Tao SU(494) Mutual Authentication Scheme for Muliti-Server Environment without Using Smart Cards⋯...
2. bluedroid 1. 硬件问题 2. 软件问题 3. 由于 android8.0 以后的蓝牙协议栈默认需要 BLE 功能,所以必须使用具备 ble 功
小明去出差,中间旅游了几次,如果A车票的出发点城市和B车票的到站城市相同,则算旅游一次。 第一行,输入整数n,代表车票的个数 下面n行代表按时间顺序排的车票信息 比如: 输入: ...Beijing Fuzhou
前言I目录 II11.11.2Rockchip SDMMC SDIO eMMC 开发指南Copyright 2016 @Fuzhou Rockchip Elec
using the methods of CPA and K-means to creat a driving cycle about Fuzhou city.there's demo and data with specific description for your reference.
XmlNodeList GWP_NodeList = GoogleWeatherAPI_Parser(@"http://www.google.com/ig/api?weather=FuZhou&hl=zh-cn").SelectNodes("xml_api_reply/weather/current_conditions"); Label l = new Label(); l.Text =...
Fuzhou, Fujian / P.R.China, The State Key Laboratory of Structural Chemistry, Fujian Institute of Research on the Structure of Matter, the Chinese Academy of Sciences Received May 16th, 2002. ...
Fuzhou, Fujian / P.R.China, The State Key Laboratory of Structural Chemistry, Fujian Institute of Research on the Structure of Matter, the Chinese Academy of Sciences Received May 16th, 2002. ...
福州大学(Fuzhou University),简称福大,创建于1958年,是国家“世界一流学科建设高校”,国家“211工程”重点建设高校,国家教育部、国家国防科技工业局与福建省人民政府共建高校,福建省三所重点建设的高水平...
【文献出处】福州大学学报, Journal of Fuzhou University, 编辑部邮箱 2008年 S1期 期刊荣誉:中文核心期刊要目总览 ASPT来源刊 CJFD收录刊【关键词】[url=]网络控制系统[/url]; [url=]ActiveX[/url]; [url=]...
Issued by dxHe on Jun 19,2008 Fuzhou Fujian China(Surrex China) Lastest version: 2.3.0.0 Prior version: 2.2.1.2 ///////////////////////////////////////////////////// dsoframer.ocx 2.3.0.0 Release ...
福州统计年鉴《福州统计年鉴2017》是一部全面反映福州市国民经济和社会发展情况的资料性年刊。全书收录了2016年福州市及所辖各县(市)、区、各部门经济和社会发展等各方面的统计数据,以及重要历史年份福州市国民经济...
☆福州 http://www.114mo.com/fuzhou/ ☆佛山http://www.114mo.com/foshan/ ☆广州 http://www.114mo.com/guangzhou/ ☆贵阳 http://www.114mo.com/guiyang/ ☆桂林 http://www.114mo.com/guilin/ ☆高雄 ...