【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

车是可以被吃掉的。。。
注意这个情况。
其他的模拟即可。

【代码】

#include <bits/stdc++.h>
using namespace std; const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
const int dx1[8] = {-1,-2,-2,-1,1,2,2,1};
const int dy1[8] = {-2,-1,1,2,-2,-1,1,2};
const int spe[8][2]={
{0,-1},
{-1,0},
{-1,0},
{0,1},
{0,-1},
{1,0},
{1,0},
{0,1}
}; const int N = 7; struct abc{
int kind,x,y;
}; int n,x,y;
abc a[N+10]; bool exsit(int x,int y){
for (int i = 1;i <= n;i++)
if (a[i].x==x && a[i].y==y)
return 1;
return 0;
} bool check(){
for (int i = 1;i <= n;i++){
if (a[i].kind==0){
if (a[i].y==y){
bool ok = 0;
for (int j = 1;j <= n;j++)
if (a[j].y==y && a[j].x>x && a[j].x<a[i].x)
ok = 1;
if (!ok) return 0;
}
}
if (a[i].kind==1){
if (a[i].y==y){
if (a[i].x==x) continue;
bool ok = 0;
for (int j = 1;j <= n;j++)
if (a[j].y==y && a[j].x>min(a[i].x,x) && a[j].x<max(a[i].x,x))
ok = 1;
if (!ok) return 0;
}
if (a[i].x==x){
if (a[i].y==y) continue;
bool ok = 0;
for (int j = 1;j <= n;j++)
if (a[j].x==x && a[j].y>min(a[i].y,y) && a[j].y<max(a[i].y,y))
ok = 1;
if (!ok) return 0;
}
}
if (a[i].kind==2){
for (int j = 0;j < 8;j++){
int nex = a[i].x + dx1[j],ney = a[i].y+dy1[j];
if (nex==x && ney==y){
if (!exsit(a[i].x+spe[j][0],a[i].y+spe[j][1])) return 0;
}
}
}
if (a[i].kind==3){
if (a[i].x==x){
int cnt = 0;
for (int j = 1;j <= n;j++)
if (a[j].x==x && a[j].y>min(a[i].y,y) && a[j].y<max(a[i].y,y))
cnt++;
if (cnt==1) return 0;
}
if (a[i].y==y){
int cnt = 0;
for (int j = 1;j <= n;j++)
if (a[j].y==y && a[j].x>min(a[i].x,x) && a[j].x<max(a[i].x,x))
cnt++;
if (cnt==1) return 0;
}
}
}
return 1;
} int main()
{
//freopen("D://rush.txt","r",stdin);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
while (cin >> n >> x >> y){
if (n==0 && x == 0 && y==0) break;
for (int i = 1;i <= n;i++){
char s[5];
cin >> s >> a[i].x >> a[i].y;
if (s[0]=='G') a[i].kind = 0;
if (s[0]=='R') a[i].kind = 1;
if (s[0]=='H') a[i].kind = 2;
if (s[0]=='C') a[i].kind = 3;
}
int ok = 0;
for (int i = 0;i < 4;i++){
x += dx[i],y+=dy[i];
if (x>3 || x<1 || y < 4 || y>6) {
x-=dx[i],y-=dy[i];
continue;
}
if (check()) ok = 1;
x -= dx[i],y-=dy[i];
}
if (ok)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
return 0;
}

【习题4-1 Uva1589】Xiangqi的更多相关文章

  1. UVA1589 Xiangqi

    Xiangqi is one of the most popular two-player board games in China. The game represents a battle bet ...

  2. [刷题]算法竞赛入门经典(第2版) 4-1/UVa1589 - Xiangqi

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1589 #include<iostream> #incl ...

  3. UVA1589——xiangqi

    开始碰到这个题时觉得太麻烦了直接跳过没做,现在放假了再次看这个题发现没有想象中那么麻烦,主要是题目理解要透彻,基本思路就是用结构体数组存下红方棋子,让黑将军每次移动一下,看移动后是否有一个红方棋子可以 ...

  4. 算法习题---4-1象棋(UVa1589)

    一:题目 在黑方只有一个“将”的情况下,红方只有(车.马.炮)(可以多个).帅的情况下,判断黑方是否被将死 (一)题目详解 其中棋盘按照坐标方式表示,左上角为(,),列数最大9,行数最大10 G 表示 ...

  5. Sharepoint学习笔记—习题系列--70-576习题解析 --索引目录

        Sharepoint学习笔记—习题系列--70-576习题解析  为便于查阅,这里整理并列出了70-576习题解析系列的所有问题,有些内容可能会在以后更新. 需要事先申明的是:     1. ...

  6. 《python核心编》程课后习题——第三章

    核心编程课后习题——第三章 3-1 由于Python是动态的,解释性的语言,对象的类型和内存都是运行时确定的,所以无需再使用之前对变量名和变量类型进行申明 3-2原因同上,Python的类型检查是在运 ...

  7. 习题 5: 更多的变量和打印 | 笨办法学 Python

    一. 简述 “格式化字符串(format string)” -  每一次你使用 ' ’ 或 " " 把一些文本引用起来,你就建立了一个字符串. 字符串是程序将信息展示给人的方式. ...

  8. 【WebGoat习题解析】Parameter Tampering->Bypass HTML Field Restrictions

    The form below uses HTML form field restrictions. In order to pass this lesson, submit the form with ...

  9. python核心编程(第二版)习题

    重新再看一遍python核心编程,把后面的习题都做一下.

随机推荐

  1. javascript 数组,数组中加入新元素 push() ,unshift() 相当于Add()

    <1> var   a   =   [];     //建立数组 push   方法     将新元素加入到一个数组中,并返回数组的新长度值.

  2. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决

    (1)我用的是fragment,在onStop但是没有onDestroy的情况下切换(replace)fragment时报 java.lang.IllegalStateException: Can n ...

  3. 二分图染色模板(P1330 封锁阳光大学)

    二分图染色模板(P1330 封锁阳光大学) 题目描述 曹是一只爱刷街的老曹,暑假期间,他每天都欢快地在阳光大学的校园里刷街.河蟹看到欢快的曹,感到不爽.河蟹决定封锁阳光大学,不让曹刷街. 阳光大学的校 ...

  4. Codeforces--629B--Far Relative’s Problem(模拟)

    Far Relative's Problem Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I ...

  5. python关于文件的操作

    总是记不住API.昨晚写的时候用到了这些,但是没记住,于是就索性整理一下吧: python中对文件.文件夹(文件操作函数)的操作需要涉及到os模块和shutil模块. 得到当前工作目录,即当前Pyth ...

  6. 0507-php独立环境的安装与配置

    1.在一个纯英文目录下新建三个文件夹 2.安装apache(选择好版本) 过程中该填的按格式填好,其余的只更改安装目录即可 如果报错1901是安装版本的问题. 检查:安装完成后localhost打开为 ...

  7. oj测试点相关 (整理摘编)

    Accepted                          通过!(AC) Wrong Answer                  答案错.(WA) Runtime Error      ...

  8. python的搜索路径与包(package)

    python的搜索路径其实是一个列表,它是指导入模块时,python会自动去找搜索这个列表当中的路径,如果路径中存在要导入的模块文件则导入成功,否则导入失败: >>> import ...

  9. Elasticsearch之批量操作bulk

    1.bulk相当于数据库里的bash操作. 2.引入批量操作bulk,提高工作效率,你想啊,一批一批添加与一条一条添加,谁快? 3.bulk API可以帮助我们同时执行多个请求 4.bulk的格式: ...

  10. 利用 html+css 画同心圆(concentric circles)——绝对布局与相对布局

    一.css 绘制圆 #circle { width: 300px; height: 300px; background-color: #000000; border-radius: 300px; } ...