【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
车是可以被吃掉的。。。
注意这个情况。
其他的模拟即可。
【代码】
#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;
}