Anton and Chess(模拟+思维)
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(模拟+思维)的更多相关文章
- 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 ...
- D. Anton and Chess 模拟题 + 读题
http://codeforces.com/contest/734/problem/D 一开始的时候看不懂题目,以为象是中国象棋那样走,然后看不懂样例. 原来是走对角线的,长知识了. 所以我们就知道, ...
- 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 ...
- 模拟+思维 HDOJ 5319 Painter
题目传送门 /* 题意:刷墙,斜45度刷红色或蓝色,相交的成绿色,每次刷的是连续的一段,知道最终结果,问最少刷几次 模拟+思维:模拟能做,网上有更巧妙地做法,只要前一个不是一样的必然要刷一次,保证是最 ...
- Anton and Chess
Anton and Chess time limit per test 4 seconds memory limit per test 256 megabytes input standard inp ...
- 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 ...
- 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 ...
- XTUOJ 1176 I Love Military Chess(模拟)
I Love Military Chess Accepted : 45 Submit : 141 Time Limit : 1000 MS Memory Limit : 65536 KB ...
- 【29.89%】【codeforces 734D】Anton and Chess
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- Vidual Studio vs2013彻底卸载
我的win10 1803 2019年年中升级的,非常后悔,持续不间断的假死状态让人很无奈.又不舍得回退,因为很多保存的隐藏数据. 开始清理系统吧,东西越少性能越好,于是电脑就成了纯净版,甚至连 看到了 ...
- 居里先生的猜想 | 皮埃尔·居里诞辰160周年
皮埃尔·居里(Pierre Curie)先生坐在桌前,手里把玩着一块小磁铁.忽然,一道闪念跃入脑海,他为自己这个大胆的想法激动不已,忍不住伏案疾笔书写起来.不远处,一位安静的青年女子温情脉脉地注视着他 ...
- API网关从入门到放弃
前言 假设你正在开发一个电商网站,那么这里会涉及到很多后端的微服务,比如会员.商品.推荐服务等等. 那么这里就会遇到一个问题,APP/Browser怎么去访问这些后端的服务? 如果业务比较简单的话,可 ...
- 李宗盛 linux罚写
1.system v init运行级别及作用 init运行级别 作用 0 关机 1 单用户模式 2 多用户的文本界面 3 多用户的文本界面 4 多用户的文本界面 5 多用户的图形界面 6 重启 eme ...
- Shiro加盐加密
接本人的上篇文章<Shiro认证.角色.权限>,这篇文章我们来学习shiro的加盐加密实现 自定义Realm: package com.czhappy.realm; import org. ...
- 如何制作windows live writer绿色便携版
如何制作windows live writer绿色便携版 2013年10月03日 ⁄ 综合 ⁄ 共 463字 ⁄ 字号 小 中 大 ⁄ 评论关闭 制作一个绿色便携版的wlw 1.首先下载 techli ...
- 关于npm install 报错 EAI_AGAIN reason: getaddrinfo EAI_AGAIN registry.npmjs.org
在公司里使用了isa连接外网,刚开始使用npm 安装依赖的时候一直报错EAI_AGAIN reason: getaddrinfo EAI_AGAIN registry.npmjs.org,我们的老大给 ...
- LaTeX技巧96:LaTeX 图片控制命令,位置控制
LaTeX技巧96:LaTeX 图片控制命令,位置控制 2012-04-05 17:25:44 zd0303 阅读数 28512更多 分类专栏: Latex LaTeX 控制图片的位置,就是加感叹 ...
- (九)mybatis之延迟加载
一.为什么要使用延迟加载? 使用延迟加载的意义 在进行数据查询时,为了提高数据库查询性能,尽量使用单表查询,因为单表查询比多表关联查询速度快. 如果查询单表就可以满足需求,一开始先查询单表,当需要关联 ...
- (八)mybatis之多对多
一.需求分析 需求:查询所有用户的信息以及每个用户所属的组的信息 分析:一个用户可以有多个组,一个组也可以由多个用户. 多对多,可以设置一张中间表,该表存放的是用户表和组表的对应关系. 二.创建数据库 ...