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

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

给你如下规则

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

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

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

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

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<cmath>
  6. #include<string>
  7. #include<cmath>
  8. #include<set>
  9. #include<vector>
  10. #include<stack>
  11. #include<queue>
  12. #include<map>
  13. using namespace std;
  14. #define ll long long
  15. #define se second
  16. #define fi first
  17. const int INF= 0x3f3f3f3f;
  18. const int N=5e5+;
  19.  
  20. int n,x,y;
  21.  
  22. struct note{
  23. int x;
  24. int y;
  25. char c;
  26. }a[N];
  27. struct note1{
  28. int s;
  29. char q;
  30. }dis[];
  31.  
  32. int main()
  33. {
  34. cin>>n;
  35. cin>>x>>y;
  36.  
  37. for(int i=;i<=;i++)
  38. dis[i].s=INF<<;
  39.  
  40. for(int i=;i<=n;i++)
  41. {
  42. cin>>a[i].c;
  43. scanf("%d%d",&a[i].x,&a[i].y);
  44. if( a[i].y==y && a[i].x-x> && dis[].s>a[i].x-x ){
  45. dis[].s = a[i].x -x;
  46. dis[].q = a[i].c; //最近的更新为 c
  47. }
  48. else if( a[i].y==y && x-a[i].x> && dis[].s>x-a[i].x ){
  49. dis[].s = x- a[i].x ;
  50. dis[].q = a[i].c; //最近的更新为 c
  51. }
  52. else if( a[i].x==x && a[i].y-y> && dis[].s>a[i].y-y ){
  53. dis[].s = a[i].y -y;
  54. dis[].q = a[i].c; //最近的更新为 c
  55. }
  56. else if( a[i].x==x && y-a[i].y> && dis[].s>y-a[i].y ){
  57. dis[].s = y- a[i].y ;
  58. dis[].q = a[i].c; //最近的更新为 c
  59. }
  60. 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))
  61. {
  62. dis[].s =abs(a[i].x-x);
  63. dis[].q = a[i].c;
  64. }
  65. 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))
  66. {
  67. dis[].s =abs(a[i].x-x);
  68. dis[].q = a[i].c;
  69. }
  70. 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))
  71. {
  72. dis[].s =abs(a[i].x-x);
  73. dis[].q = a[i].c;
  74. }
  75. 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))
  76. {
  77. dis[].s =abs(a[i].x-x);
  78. dis[].q = a[i].c;
  79. }
  80. }
  81. int flag=;
  82. for(int i=;i<=;i++)
  83. {
  84. if(dis[i].q=='R'||dis[i].q=='Q') flag=;
  85. }
  86. for(int i=;i<=;i++)
  87. {
  88. if(dis[i].q=='B'||dis[i].q=='Q') flag=;
  89. }
  90. if(flag) cout<<"YES";
  91. else cout<<"NO";
  92. }

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. pip3快速下载paddle

    安装百度的paddle paddle时很慢,后来采用国内的源,速度嗖嗖滴 pip3 install -U paddlepaddle -i https://pypi.douban.com/simple/ ...

  2. python获取昨日日期

    获取昨日日期oneday = datetime.timedelta(days=1) 一天 day = datetime.datetime.strptime(self.date,'%Y-%m-%d') ...

  3. python爬虫的入门问题

    第一张图是代码,爬的是亚马逊的一个商品网页,能爬出来内容,但是内容之间有很多空白换行,这是什么原因?要怎么解决?

  4. Python 用hashlib求中文字符串的MD5值 (转自 haungrui的专栏)

    使用过hashlib库的朋友想必都遇到过以下的错误吧:“Unicode-objects must be encoded before hashing”,意思是在进行md5哈希运算前,需要对数据进行编码 ...

  5. ACMComputerFactory(POJ-3436)【最大流】

    题目链接:https://vjudge.net/problem/POJ-3436 题意:要用N台机器来组装电脑,每台电脑由P个零部件构成,每一台机器的输入电脑和输出电脑的每部分都有各自的属性,机器本身 ...

  6. Excel常见文本清洗函数

    1.=LEFT(text,[num_chars]) ​ 函数RIGHT具有相似功能 例如选出K列中,从左数前一个字符:= LEFT(k2,1) 2.=FIND(find_text,within_tex ...

  7. ndarray笔记续

    数组的索引与切片 多维数组的索引 import numpy as np arr=np.arange(1,25).reshape(2,3,4) arr # 输出 array([[[ 1, 2, 3, 4 ...

  8. 怎样理解没有this的构造函数

    如果一个构造函数内部没有this, 那可以说这个压根不是构造函数, 因为他并不能返回一个实例对象; function Person(name) { var name = name; }; var li ...

  9. CCF 2017-09-2 公共钥匙盒

    CCF 2017-09-2 公共钥匙盒 题目 问题描述 有一个学校的老师共用N个教室,按照规定,所有的钥匙都必须放在公共钥匙盒里,老师不能带钥匙回家.每次老师上课前,都从公共钥匙盒里找到自己上课的教室 ...

  10. ASP.NET Core 入门(1)(搭建环境CentOS)

    一.CentOS 7 安装 下载CentOS http://isoredirect.centos.org/centos/7/isos/x86_64/  选择其中下载即可. 下载完成后打开vmware准 ...