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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. Cocos2d-x飞机大战教程笔记

    咳咳~跟着大神的教程学做Cocos2d-x的飞机大战...鉴于我是那种跟着教程都会出非常多错的人,所以还是一路跟着做些笔记比較好.并且因为是用课余时间,所以仅仅能断断续续地做,写下来也好让自己别忘记~ ...

  2. Android shape自定义形状,设置渐变色

      <?xml version="1.0" encoding="utf-8"?> <!-- android:shape=["rect ...

  3. WinForm c# 备份 还原 数据库(Yc那些事儿 转)

    Yc那些事儿 我愿意 为了我的幸福 奋斗终生     2008-11-17 18:04 WinForm c# 备份 还原 数据库 其实是个非常简单的问题,一个Form,一个Button,一个OpenF ...

  4. [POJ 3565] Ant

    [题目链接] http://poj.org/problem?id=3565 [算法] KM算法求最小匹配 [代码] #include <algorithm> #include <bi ...

  5. OC常用的数学函数及宏定义

    一.函数 1. 三角函数 double sin (double);正弦 double cos (double);余弦 double tan (double);正切 2 .反三角函数 double as ...

  6. 【BZOJ3456】城市规划

    题目 转送门 思路&算法 我们设点数为\(n\)的简单图的数量为\(f_n\), 点数为\(n\)的简单连通图有\(g_i\)个 于是我们知道,从\(n\)个点中选\(2\)个点有\(n \c ...

  7. P1966 火柴排队(逆序对)

    P1966 火柴排队 题目描述 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度. 现在将每盒中的火柴各自排成一列, 同一列火柴的高度互不相同, 两列火柴之间的距离定义为: ∑(ai-bi) ...

  8. web动画小结

    前端写动画,无非两种方案,一种是通过css,另一种是js css的方案: 1.transform的单独使用 (IE9+) rotate(90deg) 2d旋转,也可以理解为沿着3D的Z轴旋转 rota ...

  9. linux ssh文件输

    在linux下一般用scp这个命令来通过ssh传输文件. 1.从服务器上下载文件scp username@servername:/path/filename /var/www/local_dir(本地 ...

  10. POJ 1082---->一个神一般的题

    代码只有10行,反正我是看了题解才知道的. 嗯 首先 看到这个题, BFS+一堆判断(什么平年闰年跨年各种乱搞肯定能搞出来,但是Code length就不一定了)... 然后呢 就看到了这个题解 从后 ...