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) ...
随机推荐
- ios非UTF-8格式的网页解析
网上有很多关于ios xml解析的方法,关于非UTF-8格式的网页解析也不少,我也试着看了好几个,但都没成功.今天无意中却弄好了,所以想和大家分享下.其实很简单,下面说下怎么得到非UTF-8格式的网页 ...
- 盈创动力之 JS校验方法
var IS_NULL = 128; // 10000000var IS_FULL = 64; // 01000000var IS_HALF = 32; // 00100000var IS_ASCII ...
- Linux下C语音实现socket发送和接收的小程序
1.什么是socket套接字 socket其实就是计算机通信的端口,可以实现两个计算机之间的通信的一个接口,应用程序在网络上传输就是通过这个借口实现. socket分为三种类型: 字节流套接字(Str ...
- vue-router 获得上一级路由以及返回上一级路由的方法
if (this.$store.state.previousRouter.name) { this.$router.push({name: this.$store.state.previousRout ...
- 洛谷P1119灾后重建——Floyd
题目:https://www.luogu.org/problemnew/show/P1119 N很小,考虑用Floyd: 因为t已经排好序,所以逐个加点,Floyd更新即可: 这也给我们一个启发,如果 ...
- 11.boolean类型
/* 关于java中的Boolean类型: 1)赋给boolean类型的值只有两个:ture或者false 2)boolean类型的数据主要用在逻辑运算和条件控制语句中.*/ public class ...
- zlog日志库的简单封装,以及给debug级别添加颜色显示
现看看效果如何: 方法如下: 定义相关颜色的宏 #define ESC_START "\033[" #define ESC_END "\033[0m" #def ...
- windows: Python安装scipy,scikit-image时提示"no lapack/blas resources found"的解决方法
解决方案: 最后,解决我遇到的这个问题的解决方案是来自以下链接的答案: http://www.voidcn.com/blog/z6491679/article/p-5740396.html. 另外还有 ...
- hdu-2141
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- 【Hadoop】MapReduce笔记(三):MapReduce的Shuffle和Sort阶段详解
一.MapReduce 总体架构 整体的Shuffle过程包含以下几个部分:Map端Shuffle.Sort阶段.Reduce端Shuffle.即是说:Shuffle 过程横跨 map 和 reduc ...