http://codeforces.com/group/1EzrFFyOc0/contest/734/problem/D

题意:就是给你一个很大的棋盘,给你一个白棋的位置还有n个黑棋的位置,问你黑棋能否一步就吃掉白棋

给你如下规则

1.‘B‘只能对角线移动,而且不能越过其他黑棋。

2.’R‘只能上下左右移动,而且不能越过其他黑棋。

3.‘Q’既能对角线移动又能左右移动,但是不能越过其他黑棋。

这是看了别人的代码,很长,但只是粘贴复制,再改一下一下就行了;

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
#define se second
#define fi first
const int INF= 0x3f3f3f3f;
const int N=5e5+; int n,x,y; struct note{
int x;
int y;
char c;
}a[N];
struct note1{
int s;
char q;
}dis[]; int main()
{
cin>>n;
cin>>x>>y; for(int i=;i<=;i++)
dis[i].s=INF<<; for(int i=;i<=n;i++)
{
cin>>a[i].c;
scanf("%d%d",&a[i].x,&a[i].y);
if( a[i].y==y && a[i].x-x> && dis[].s>a[i].x-x ){
dis[].s = a[i].x -x;
dis[].q = a[i].c; //最近的更新为 c
}
else if( a[i].y==y && x-a[i].x> && dis[].s>x-a[i].x ){
dis[].s = x- a[i].x ;
dis[].q = a[i].c; //最近的更新为 c
}
else if( a[i].x==x && a[i].y-y> && dis[].s>a[i].y-y ){
dis[].s = a[i].y -y;
dis[].q = a[i].c; //最近的更新为 c
}
else if( a[i].x==x && y-a[i].y> && dis[].s>y-a[i].y ){
dis[].s = y- a[i].y ;
dis[].q = a[i].c; //最近的更新为 c
}
else if(abs(a[i].x-x)==abs(a[i].y-y) && a[i].x>x &&a[i].y>y &&dis[].s>abs(a[i].x-x))
{
dis[].s =abs(a[i].x-x);
dis[].q = a[i].c;
}
else if(abs(a[i].x-x)==abs(a[i].y-y) && a[i].x<x &&a[i].y>y &&dis[].s>abs(a[i].x-x))
{
dis[].s =abs(a[i].x-x);
dis[].q = a[i].c;
}
else if(abs(a[i].x-x)==abs(a[i].y-y) && a[i].x<x &&a[i].y<y &&dis[].s>abs(a[i].x-x))
{
dis[].s =abs(a[i].x-x);
dis[].q = a[i].c;
}
else if(abs(a[i].x-x)==abs(a[i].y-y) && a[i].x>x &&a[i].y<y &&dis[].s>abs(a[i].x-x))
{
dis[].s =abs(a[i].x-x);
dis[].q = a[i].c;
}
}
int flag=;
for(int i=;i<=;i++)
{
if(dis[i].q=='R'||dis[i].q=='Q') flag=;
}
for(int i=;i<=;i++)
{
if(dis[i].q=='B'||dis[i].q=='Q') flag=;
}
if(flag) cout<<"YES";
else cout<<"NO";
}

Anton and Chess(模拟+思维)的更多相关文章

  1. Codeforces Round #379 (Div. 2) D. Anton and Chess 模拟

    题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmem ...

  2. D. Anton and Chess 模拟题 + 读题

    http://codeforces.com/contest/734/problem/D 一开始的时候看不懂题目,以为象是中国象棋那样走,然后看不懂样例. 原来是走对角线的,长知识了. 所以我们就知道, ...

  3. Codeforces Round #379 (Div. 2) D. Anton and Chess 水题

    D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...

  4. 模拟+思维 HDOJ 5319 Painter

    题目传送门 /* 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最 ...

  5. Anton and Chess

    Anton and Chess time limit per test 4 seconds memory limit per test 256 megabytes input standard inp ...

  6. Codeforces Round #379 (Div. 2) D. Anton and Chess —— 基础题

    题目链接:http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test 4 seconds me ...

  7. Codeforces 734D. Anton and Chess(模拟)

    Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the pro ...

  8. XTUOJ 1176 I Love Military Chess(模拟)

     I Love Military Chess Accepted : 45   Submit : 141 Time Limit : 1000 MS   Memory Limit : 65536 KB ...

  9. 【29.89%】【codeforces 734D】Anton and Chess

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. VBA方法总结

    1.取得日文汉字的读音的方法(例如強→キョウ) Application.Getphonetic(str) 2.保存Excel文件时不弹出是否保存的alter wb.close(false) 3.提示消 ...

  2. MySQL安装时出现的问题

    mysql正常安装结束之后需要连接你所安装的数据库的时候出现下面的错误: Client does not support authentication protocol requested by se ...

  3. 南柯33的Python学习笔记第(一)部分

    Python基础 1.Python简介 1.1 Python是什么编程语言 从编程语言的几个方向来说 编译型和解释型 什么是编译型?什么是解释型? 编译型:就是把源代码一下全部都编译成二进制文件(优点 ...

  4. 封装Json+日志

    /** * 输出json * @param $msg * @param int $errno */ public function printOutError($msg = '操作失败', $errn ...

  5. [转帖]Linux 中的零拷贝技术,第 2 部分

    Linux 中的零拷贝技术,第 2 部分 https://www.ibm.com/developerworks/cn/linux/l-cn-zerocopy2/index.html   Linux 中 ...

  6. [转帖]Linux Shell常用技巧(五)

    Linux Shell常用技巧(五) https://zhuanlan.zhihu.com/p/73451771 1. 变量:在awk中变量无须定义即可使用,变量在赋值时即已经完成了定义.变量的类型可 ...

  7. [转帖]当 K8s 集群达到万级规模,阿里巴巴如何解决系统各组件性能问题?

    改天学习一下. https://www.cnblogs.com/alisystemsoftware/p/11570806.html   当 K8s 集群达到万级规模,阿里巴巴如何解决系统各组件性能问题 ...

  8. Spring IoC 和 DI 简介(二)

    Spring IoC 和 DI 简介 IoC:Inverse of Control(控制反转) 读作“反转控制”,更好理解,不是什么技术,而是一种设计思想,就是将原本在程序中手动创建对象的控制权,交由 ...

  9. VC++操作注册表(创建,读取,更改,删除)

    #include "stdafx.h" #include <Windows.h> #include <iostream> using namespace s ...

  10. python day1 (afternoon)购物清单

    购物清单 #顾客给出余额 #给出商品清单 #顾客挑选商品 #给出购物清单 代码: #!/usr/bin/env python#-*- coding:utf-8 -*- salary = int(inp ...