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) ...
随机推荐
- jenkins页面不刷新,设置tomcat缓存
装jenkins的时候,部署后,访问jenkins页面,输入管理员密码后,出现jenkins页面停滞,看后台catlina日志,发现需要增加tomcat容器的cache,才能加载一些jar包,下面是设 ...
- iOS7默认状态栏文字颜色为黑色,项目需要修改为白色。
1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的 AppDelegate中在 didFinishLaun ...
- bind (ERROR 502): bind(0.0.0.0:9501) failed. Error: Address already in use [98] (端口被占用)
运行 swoole_server 服务报错显示端口被占用 解决思路: 1.用命令查看该端口 看是否存在 netstat -anp | grep 9501 2.如果存在 就用 kill对应端口号 ...
- json数组对象和对象数组 ---OK
一.Json的简单介绍 从结构上看,所有的数据最终都可以分成三种类型: 第一种类型是scalar(标量),也就是一个单独的string(字符串)或数字(numbers),比如“北京”这个单独的词. 第 ...
- JQuery扩展插件Validate—5添加自定义验证方法
从前面的示例中不难看出validate中自带的验证方法足以满足一般的要求,对于特别的要求可以使用addMethod(name,method,message)添加自定义的验证规则,下面的示例中添加了一个 ...
- C语言--递归问题
1,一个经典的例子,理解递归过程的展开 #include<stdio.h> void func(int i){ ) func(i/); printf("%d",i) } ...
- Httpclient入门代码
/** * Project Name:httpClient * File Name:Test.java * Package Name:httpClient * Date:2017年11月9日上午8:3 ...
- 20个Flutter实例视频教程-第02节: 底部导航栏制作-2
视频地址: https://www.bilibili.com/video/av39709290?p=2 博客地址: https://jspang.com/post/flutterDemo.html#t ...
- CodeForces 689C【二分】
转自: http://blog.csdn.net/qq_26071477/article/details/51892995 #include<stdio.h> typedef long l ...
- C#获得当前执行的函数名、当前代码行、源代码文件名
http://blog.csdn.net/newegg2009/article/details/6220385 C#获得当前执行的函数名.当前代码行.源代码文件名 [日期:2010-10-18 11: ...