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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. 【Allwinner ClassA20类库分析】4.GPIO类的使用

        从本节起,開始使用ClassA20类库完毕操作外设的功能,请先在https://github.com/tjCFeng/ClassA20下载ClassA20类库. 封装的目的就是简化操作,试想一 ...

  2. 创造HTTPS的是个神

    HTTP 是一个明文传输的协议,很多网络监听工具都可以轻易窃取网络中传输的用户信息,如密码,信用卡, 直到后来发明HTTPS, 世界一下子安静了 Why HTTPS? HTTPS可以保证用户提交的信息 ...

  3. QT 4.53 for VS2005 编译包

    最近学QT,装了QT5,结果打开下载的项目(特别是那些书的源代码)有很多兼容性问题.于是又下载4.83,都是4版本系列的,应该会好很多吧,但居然也是这样.于是看了一下时间,觉得4.53于2009年底发 ...

  4. oc60--Category 分类 练习

    // main.m // Category练习 #import <Foundation/Foundation.h> #import "NSString+NJ.h" // ...

  5. Android Calendar的运用

    import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; impo ...

  6. E20170829-mk

    Parse   vt. 从语法上描述或分析(词句等); serial    adj. 连续的; 连载的; 顺序排列的; 分期偿付的; MultiThread n. 多线程; 多流; concurren ...

  7. [BZOJ2321,LuoguP1861]星(之)器

    丧心病狂的神仙题 丧心病狂的神仙题 丧心病狂的神仙题 显然,不管你怎么移动,答案都是一定的 然后我们很快能联系到物理里面的能量守恒,于是自然地我们要给每个点搞一个势能出来 然后把势能的表达式写出来就可 ...

  8. RabbitMQ .NET消息队列使用入门(一)【简单示例】

    首先下载安装包,我都环境是win7 64位: 去官网下载 otp_win64_19.0.exe 和rabbitmq-server-3.6.3.exe安装好 然后开始编程了: (1)创建生产者类: cl ...

  9. 6月10遇到的bug

    3.遇到的BUG        1.@Service(version = "1.0.0", interfaceClass = TransactionItemService.clas ...

  10. JavaScript 判断手机端操作系统(Andorid/IOS)

    androidURL = "http://xxx/xxx.apk"; var browser = { versions: function() { var u = navigato ...