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) ...
随机推荐
- AndroidManifest配置之uses-sdk
uses-sdk配置 uses-sdk用来设置app对android系统的兼容性.它包含三个可选的配置项,分别为android:minSdkVersion,android:targetSdkVersi ...
- hdu-5670 Machine(水题附上java代码)
题目链接: Machine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描 ...
- I.MX6 Surfaceflinger 机制
/**************************************************************************** * I.MX6 Surfaceflinger ...
- c/c++生成预编译文件
Preprocesses C and C++ source files and writes the preprocessed output to a file. /P Remarks The f ...
- IDEA 设置背景颜色及字号
intellij IDEA 设置背景颜色 File--> Settings 2. Appearance & Behavior --> Appearance 设置边框背景颜色 3 ...
- vue不支持IE8的原因
当你把一个普通的 JavaScript 对象传给 Vue 实例的 data 选项,Vue 将遍历此对象所有的属性, 并使用 Object.defineProperty 把这些属性全部转为 getter ...
- 洛谷P4009汽车加油行驶问题——网络流24题(最短路)
题目:https://www.luogu.org/problemnew/show/P4009 网络流24题中不是网络流的最短路题: 把每个点拆成各个油量上的点,根据要求连边即可: 注意:点数最大为10 ...
- 机器学习之K-means算法
前言 以下内容是个人学习之后的感悟,转载请注明出处~ 简介 在之前发表的线性回归.逻辑回归.神经网络.SVM支持向量机等算法都是监督学习算法,需要样本进行训练,且 样本的类别是知 ...
- Ubuntu环境下gedit以及vim的一些个简单配置
Gedit的配置: 参见 http://www.cnblogs.com/csulennon/p/4198054.html Gedit插件安装 Gedit快捷键 参见我的博客 添加快捷键 Ctrl + ...
- LeetCode: 620 Not Boring Movies(easy)
题目: X city opened a new cinema, many people would like to go to this cinema. The cinema also gives o ...