D. Anton and Chess 模拟题 + 读题
http://codeforces.com/contest/734/problem/D
一开始的时候看不懂题目,以为象是中国象棋那样走,然后看不懂样例。
原来是走对角线的,长知识了。
所以我们就知道,王有八个方向,所以每个方向选一个来做代表就行了。
那么选谁呢?可以排序,按照他们离王的距离从小到大排,这样就能选出最近的那个(不用被棋挡住)
然后注意下方向的表达,在王的右上角,还要和王在同一对角线才行~不能简单地判x和y的大小关系
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = + ;
LL xx0, yy0;
struct node {
char ch;
LL x, y;
node() {}
node(char cc, LL xx, LL yy) : ch(cc), x(xx), y(yy) {}
bool operator < (const struct node & rhs) const {
LL dis = (x - xx0) * (x - xx0) + (y - yy0) * (y - yy0);
LL dis2 = (rhs.x - xx0) * (rhs.x - xx0) + (rhs.y - yy0) * (rhs.y - yy0);
return dis < dis2;
}
}arr[maxn];
vector<struct node>pos[];
void work() {
IOS;
int n;
cin >> n;
cin >> xx0 >> yy0;
for (int i = ; i <= n; ++i) {
char str[];
cin >> str;
arr[i].ch = str[];
cin >> arr[i].x >> arr[i].y;
}
sort(arr + , arr + + n);
// for (int i = 1; i <= n; ++i) {
// cout << arr[i].ch << " " << arr[i].x << " " << arr[i].y << endl;
// }
for (int i = ; i <= n; ++i) {
int face = ;
if (arr[i].x == xx0 && arr[i].y > yy0) face = ;
else if (arr[i].x < xx0 && arr[i].y > yy0 && arr[i].x + arr[i].y == xx0 + yy0) face = ;
else if (arr[i].y == yy0 && arr[i].x < xx0) face = ;
else if (arr[i].x < xx0 && arr[i].y < yy0 && arr[i].x - arr[i].y == xx0 - yy0) face = ;
else if (arr[i].x == xx0 && arr[i].y < yy0) face = ;
else if (arr[i].x > xx0 && arr[i].y < yy0 && arr[i].x + arr[i].y == xx0 + yy0) face = ;
else if (arr[i].y == yy0 && arr[i].x > xx0) face = ;
else if (arr[i].x > xx0 && arr[i].y > yy0 && arr[i].x - arr[i].y == xx0 - yy0) face = ;
if (pos[face].size() != ) continue;
pos[face].push_back(arr[i]);
}
// cout << "fff" << endl;
for (int i = ; i <= ; ++i) {
if ((i == || i == ) && pos[i].size() && (pos[i][].ch == 'Q' || pos[i][].ch == 'R')) {
printf("YES\n");
return;
} else if ((i == || i == ) && pos[i].size() && (pos[i][].ch == 'Q' || pos[i][].ch == 'B')) {
printf("YES\n");
return;
} else if ((i == || i == ) && pos[i].size() && (pos[i][].ch == 'Q' || pos[i][].ch == 'R')) {
printf("YES\n");
return;
} else if ((i == || i == ) && pos[i].size() && (pos[i][].ch == 'B' || pos[i][].ch == 'Q')) {
printf("YES\n");
return;
}
}
printf("NO\n");
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}
D. Anton and Chess 模拟题 + 读题的更多相关文章
- Codeforces 659B Qualifying Contest【模拟,读题】
写这道题题解的目的就是纪念一下半个小时才读懂题...英文一多读一读就溜号... 读题时还时要静下心来... 题目链接: http://codeforces.com/contest/659/proble ...
- 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 ...
- ZOJ 3652 Maze 模拟,bfs,读题 难度:2
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4842 要注意题目中两点: 1.在踏入妖怪控制的区域那一刹那,先减行动力,然后才 ...
- 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 ...
- 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 ...
- 2017 五一 清北学堂 Day1模拟考试结题报告
预计分数:100+50+50 实际分数:5+50+100 =.= 多重背包 (backpack.cpp/c/pas) (1s/256M) 题目描述 提供一个背包,它最多能负载重量为W的物品. 现在给出 ...
- 杭电ACM2076--夹角有多大(题目已修改,注意读题)
杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...
- 【托业】【全真题库】TEST01-03-阅读题
[托业][全真题库]TEST01-03-阅读题
- HDUOJ--2079选课时间(题目已修改,注意读题)
选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
随机推荐
- hadoop集群部署后,遇到的问题记录
1. 部署完,启动集群后,mapred-site.xml文件中配置没有生效 <property> <name>mapred.job.tracker</name> ...
- python 函数定义
我们可以创建一个函数来列出费氏数列 >>> def fib(n): # write Fibonacci series up to n ... """Pr ...
- bootstrap 学习笔记(2)---- 排版
安装和栅格系统学完,这篇写的是排版手册中排版的目录如下图 <标题,页面主题,内联文本元素,对齐,改变大小写,缩略语,地址,引用,列表>手册中介绍那么多,其实并不是所有的都要去看看.很多都是 ...
- shell之sort和uniq 及wc 的使用
文本排序:sort -n:数值排序 -r: 降序 -t: 字段分隔符 -k: 以哪个字段为关键字进行排序 -u: 排序后相同的行只显示一次 ...
- 「LuoguP3796」 【模板】AC自动机(加强版)
题目描述 有N个由小写字母组成的模式串以及一个文本串T.每个模式串可能会在文本串中出现多次.你需要找出哪些模式串在文本串T中出现的次数最多. 输入输出格式 输入格式: 输入含多组数据. 每组数据的第一 ...
- AtCoder Grand Contest 007 E:Shik and Travel
题目传送门:https://agc007.contest.atcoder.jp/tasks/agc007_e 题目翻译 现在有一个二叉树,除了叶子每个结点都有两个儿子.这个二叉树一共有\(m\)个叶子 ...
- 1.7-1.12 MapReduce Wordflow
一.案例运行MapReduce Wordflow 1.准备examples [root@hadoop-senior oozie-4.0.0-cdh5.3.6]# pwd /opt/cdh-5.3.6/ ...
- MySQL(12)---纪录一次left join一对多关系而引起的BUG
MySQL(11)---纪录一次left join一对多关系而引起的bug BUG背景 我们有一个订单表 和 一个 物流表 它们通过 订单ID 进行一对一的关系绑定.但是由于物流表在保存订单信息的时候 ...
- meta标签常用属性
Keywords(关键词) 说明:告诉搜索引擎你网页的关键字(keywords)使用方法:<meta name="keywords" content="标签,属性, ...
- 51nod1010【二分】
打表+二分 #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL inf=1e18+10 ...