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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. 配置Java连接池的两种方式:tomcat方式以及spring方式

    1. tomcat方式:在context.xml配置连接池,然后在web.xml中写配置代码(也能够在server.xml文件里配置连接池).这两种方法的差别是:在tomcat6版本号及以上中cont ...

  2. HDU - 3622 Bomb Game(二分+2-SAT)

    题目大意:玩一个放炸弹游戏,有N次放炸弹的机会,每次放炸弹时,你都有两个位置能够选择.问怎样放炸弹,能使爆炸的炸弹的半径的最小值最大(炸弹爆炸半径能够控制,可是爆炸形成的圈不能有重叠部分) 解题思路: ...

  3. uboot向内核模块传递参数的方法

    1 模块参数 定义模块参数 1 module_param(name, type, perm); 定义一个模块参数, name 变量名 type 数据类型 bool:布尔型 invbool:一个布尔型( ...

  4. Android按键添加和处理的方案【转】

    本文转载自:http://www.cnblogs.com/skywang12345/p/3142851.html Android按键添加和处理的方案  版本号 说明 作者 日期  1.0  Andro ...

  5. 【BZOJ 1230】 开关灯

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1230 [算法] 线段树 [代码] #include<bits/stdc++.h ...

  6. [NOI2018]归程(80pts)

    https://www.zybuluo.com/ysner/note/1219964 题面 题面太长,难以概述,[戳我][1] \(ex10pts\ tree\) \(50pts\ n\leq1500 ...

  7. SpringMVC使用POST方法传递数据,却出现Request method 'GET' not supported?

    转自:https://segmentfault.com/q/1010000011245770 问题:没有使用get获取当前页面解决方案:   @RequestMapping(value = " ...

  8. python 函数参数的传递(参数带星号的说明)

    python中函数参数的传递是通过赋值来传递的.函数参数的使用又有俩个方面值得注意:1.函数参数是如何定义的 2.在调用函数的过程中参数是如何被解析 先看第一个问题,在python中函数参数的定义主要 ...

  9. 3.2 手机中的数据库——SQLite

    http://www.sqlite.org/download.html 截至我安装SQLite数据库为止的时间,最新的版本可以下载sqlite-dll-win64-x64-3200000.zip和sq ...

  10. Node.js+express 4.x 入门笔记

    一.新建node项目并实现访问 二.在express4.x下,让ejs模板文件,使用扩展名为html的文件 三.实现路由功能 四.session使用 五.页面访问控制及提示 六.代码下载地址 一.新建 ...