博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Xuzhou Winter Camp 1C(模拟)
阅读量:6431 次
发布时间:2019-06-23

本文共 3180 字,大约阅读时间需要 10 分钟。

#include<iostream>

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int x[10],y[10];
int dangerous[17][17];
char z[10];
int vis[17][17];
char s[100][100];
int main(){
    int n;
    while(~scanf("%d",&n)){
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        memset(z,0,sizeof(z));
        memset(vis,0,sizeof(vis));
        memset(s,0,sizeof(s));
        memset(dangerous,0,sizeof(dangerous));
        int a,b;
        scanf("%d%d",&a,&b);
        if(n==0)
            break;
        for(int i=1;i<=n;i++){
            cin>>z[i]>>x[i]>>y[i];//getchar();scanf("%c%d%d",&z[i],&x[i],&y[i]);这种输入过不了
            vis[x[i]][y[i]]=1;
        }
        int flag=0;
        for(int i=1;i<=n;i++){
            flag=0;
            if(z[i]=='G'){
                for(int j=x[i]-1;j>=1;j--){
                    if(!vis[j][y[i]])
                        dangerous[j][y[i]]=1;
                    else{
                        dangerous[j][y[i]]=1;
                        break;
                    }
                }
                if(b==y[i]){
                    flag=0;
                    for(int ii=a+1;ii<x[i];ii++){
                        if(vis[ii][b]==1)
                            flag=1;
                    }
                    if(!flag){
                        printf("NO\n");
                        flag=10;
                        break;
                    }
                }
            }
            else if(z[i]=='R'){
                int ii=0;
                for(ii=x[i]-1;ii>=1;ii--){
                    if(!vis[ii][y[i]])
                        dangerous[ii][y[i]]=1;
                    else{
                        dangerous[ii][y[i]]=1;
                        break;
                    }
                }
                //dangerous[ii][y[i]]=1;
                for(ii=x[i]+1;ii<=10;ii++){
                    if(!vis[ii][y[i]])
                        dangerous[ii][y[i]]=1;
                    else{
                        dangerous[ii][y[i]]=1;
                        break;
                    }
                }
                //dangerous[ii][y[i]]=1;
                for(ii=y[i]-1;ii>=1;ii--){
                    if(vis[x[i]][ii]==0)
                        dangerous[x[i]][ii]=1;
                    else{
                        dangerous[x[i]][ii]=1;
                        break;
                    }
                }
                //dangerous[x[i]][ii]=1;
                for(ii=y[i]+1;ii<=9;ii++){
                    if(vis[x[i]][ii]==0)
                        dangerous[x[i]][ii]=1;
                    else{
                        dangerous[x[i]][ii]=1;
                        break;
                    }
                }
                //dangerous[x[i]][ii]=1;
            }
            else if(z[i]=='C'){
                flag=0;
                for(int ii=x[i]-1;ii>=2;ii--){
                    if(vis[ii][y[i]]==1){
                        flag=ii;
                        break;
                    }
                }
                if(flag){
                    for(int ii=flag-1;ii>=1;ii--){
                        if(vis[ii][y[i]]==0)
                            dangerous[ii][y[i]]=1;
                        else{
                            dangerous[ii][y[i]]=1;
                            break;
                        }
                    }
                }
                flag=0;
                for(int ii=x[i]+1;ii<=9;ii++){
                    if(vis[ii][y[i]]==1){
                        flag=ii;
                        break;
                    }
                }
                if(flag){
                    for(int ii=flag+1;ii<=10;ii++){
                        if(vis[ii][y[i]]==0)
                            dangerous[ii][y[i]]=1;
                        else{
                            dangerous[ii][y[i]]=1;
                            break;
                        }
                    }
                }
                flag=0;
                for(int ii=y[i]-1;ii>=2;ii--){
                    if(vis[x[i]][ii]==1){
                        flag=ii;
                        break;
                    }
                }
                if(flag){
                    for(int ii=flag-1;ii>=1;ii--){
                        if(vis[x[i]][ii]==0)
                            dangerous[x[i]][ii]=1;
                        else{
                            dangerous[x[i]][ii]=1;
                            break;
                        }
                    }
                }
                flag=0;
                for(int ii=y[i]+1;ii<=8;ii++){
                    if(vis[x[i]][ii]==1){
                        flag=ii;
                        break;
                    }
                }
                if(flag){
                    for(int ii=flag+1;ii<=9;ii++){
                        if(vis[x[i]][ii]==0)
                            dangerous[x[i]][ii]=1;
                        else{
                            dangerous[x[i]][ii]=1;
                            break;
                        }
                    }
                }
            }
            else if(z[i]=='H'){
                if(vis[x[i]-1][y[i]]==0){
                    //if(!vis[x[i]-2][y[i]-1])
                        dangerous[x[i]-2][y[i]-1]=1;
                    //if(!vis[x[i]-2][y[i]+1])
                        dangerous[x[i]-2][y[i]+1]=1;
                }
                if(vis[x[i]+1][y[i]]==0){
                    //if(!vis[x[i]+2][y[i]-1])
                        dangerous[x[i]+2][y[i]-1]=1;
                    //if(!vis[x[i]+2][y[i]+1])
                        dangerous[x[i]+2][y[i]+1]=1;
                }
                if(vis[x[i]][y[i]-1]==0){
                    //if(!vis[x[i]-1][y[i]-2])
                        dangerous[x[i]-1][y[i]-2]=1;
                    //if(!vis[x[i]+1][y[i]-2])
                        dangerous[x[i]+1][y[i]-2]=1;
                }
                if(vis[x[i]][y[i]+1]==0){
                    //if(!vis[x[i]-1][y[i]+2])
                        dangerous[x[i]-1][y[i]+2]=1;
                    //if(!vis[x[i]+1][y[i]+2])
                        dangerous[x[i]+1][y[i]+2]=1;
                }
            }
        }
        if(flag==10)
            continue;
        flag=0;
        if(a-1>=1)
            if(!dangerous[a-1][b])
                flag=1;
        if(a+1<=3)
            if(!dangerous[a+1][b])
                flag=1;
        if(b-1>=4)
            if(!dangerous[a][b-1])
                flag=1;
        if(b+1<=6)
            if(!dangerous[a][b+1])
                flag=1;
        if(flag)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

转载于:https://www.cnblogs.com/ldudxy/p/10301690.html

你可能感兴趣的文章
大话设计模式读书笔记3——单例模式
查看>>
实验三
查看>>
Vue 项目构建
查看>>
[Ruby on Rails系列]2、开发环境准备:Ruby on Rails开发环境配置
查看>>
android studio adb
查看>>
框架源码系列二:手写Spring-IOC和Spring-DI(IOC分析、IOC设计实现、DI分析、DI实现)...
查看>>
asp.net编译 懒人脚本
查看>>
二分答案经典入门题:)
查看>>
为什么你需要将代码迁移到ASP.NET Core 2.0?
查看>>
Servlet的多线程和线程安全
查看>>
存储树形的数据表转为Json
查看>>
CAN 总线通信控制芯片SJA1000 的读写
查看>>
oauth授权协议的原理
查看>>
OutputCache说明
查看>>
sdl2.0示例
查看>>
数学 --- 高斯消元 POJ 1830
查看>>
Ejabberd源码解析前奏--集群
查看>>
[ZHUAN]Flask学习记录之Flask-SQLAlchemy
查看>>
【转】Install SmartGit via PPA in Ubuntu 13.10/13.04/12.04/Linux Mint
查看>>
PNG怎么转换成32位的BMP保持透明
查看>>