CodeForces - 1033A
Alice and Bob are playing chess on a huge chessboard with dimensions n×nn×n. Alice has a single piece left — a queen, located at (ax,ay)(ax,ay), while Bob has only the king standing at (bx,by)(bx,by). Alice thinks that as her queen is dominating the chessboard, victory is hers.
But Bob has made a devious plan to seize the victory for himself — he needs to march his king to (cx,cy)(cx,cy) in order to claim the victory for himself. As Alice is distracted by her sense of superiority, she no longer moves any pieces around, and it is only Bob who makes any turns.
Bob will win if he can move his king from (bx,by)(bx,by) to (cx,cy)(cx,cy) without ever getting in check. Remember that a king can move to any of the 88 adjacent squares. A king is in check if it is on the same rank (i.e. row), file (i.e. column), or diagonal as the enemy queen.
Find whether Bob can win or not.
Input
The first line contains a single integer nn (3≤n≤1000) — the dimensions of the chessboard.
The second line contains two integers axax and ayay (1≤ax,ay≤n1≤ax,ay≤n) — the coordinates of Alice's queen.
The third line contains two integers bxbx and byby (1≤bx,by≤n1≤bx,by≤n) — the coordinates of Bob's king.
The fourth line contains two integers cxcx and cycy (1≤cx,cy≤n1≤cx,cy≤n) — the coordinates of the location that Bob wants to get to.
It is guaranteed that Bob's king is currently not in check and the target location is not in check either.
Furthermore, the king is not located on the same square as the queen (i.e. ax≠bxax≠bx or ay≠byay≠by), and the target does coincide neither with the queen's position (i.e. cx≠axcx≠ax or cy≠aycy≠ay) nor with the king's position (i.e. cx≠bxcx≠bx or cy≠bycy≠by).
Output
Print "YES" (without quotes) if Bob can get from (bx,by)(bx,by) to (cx,cy)(cx,cy) without ever getting in check, otherwise print "NO".
You can print each letter in any case (upper or lower).
Examples
Input
8
4 4
1 3
3 1
Output
YES
Input
8
4 4
2 3
1 6
Output
NO
Input
8
3 5
1 2
6 1
Output
NO
解题思路:由题意可知女王(ax,ay)所在的那一行和那一列国王(bx,by)都不能通过.这样我们就可以令(ax,ay)为原点建立平面直角坐标系,国王(bx,by)只能在其所在的象限移动,所以我们只需判断(bx,by)和(cx,cy)是否在同一象限即可。
include<stdio.h>
int main()
{
int n,xb,xc,yb,yc,y,ax,bx,cx,ay,by,cy;
while(~scanf("%d",&n))
{
scanf("%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy);
xb=bx-ax;yb=by-ay;//(xb,yb)代表以(ax,ay)为原点(bx,by)所在的位置
xc=cx-ax;yc=cy-ay;//同上
if(xb>0&&xc>0&yb>0&&yc>0||xb<0&&xc<0&&yb>0&&yc>0||xb<0&&xc<0&&yb<0&&yc<0||xb>0&&xc>0&&yb<0&&yc<0)//判断(xb,yb)和(xc,yc)是否在同一象限
printf("YES\n");
else
printf("NO\n");
}
}
CodeForces - 1033A的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- .node 文件require时候显示Error: The specified module could not be found
参考文章:https://stackoverflow.com/questions/41253450/error-the-specified-module-could-not-be-found 第一:你 ...
- 测试自动化学习3-python3简单操作
1.列表操作 增 stu = []stus.append('lili') #在list的末尾增加一个元素 stus.insert(9,'yjk') #在指定的位置插入元素, 查 print('单个取, ...
- [No000019A]【波浪理论精典教学课程】
波浪理论的产生和发展 拉尔夫·纳尔逊·艾略特(Ralph Nelson Elliott ),是波浪理论的创始人.1871年7月28日出生在美国密苏里州堪萨斯市的玛丽斯维利镇Marysville ...
- centos7内核升级及curl访问https证书过期处理
centos7内核升级及curl访问https证书过期处理 先看下当前系统的linux内核版本 uname -r 3.10.0-229.el7.x86_64 升级步骤 1.rpm --import h ...
- C++11 新特性之operator "" xxx
从C++11开始,我们可以使用以下形式通过常量字符串构造自定义类型, 比如: class Person { public: Person(const std::string& name): _ ...
- linux上查询网卡型号
- VM中centos设置子网内虚拟机ip
,首先应该设置vm的网络,打开编辑->虚拟网络编辑器,弹出框及具体设置如下图 2,选中相应的虚拟机,右键设置,并设置相应的选项,具体设置如下图 3.设置完成后,打开虚拟机,等待虚拟机启动后,输入 ...
- Jenkins+Jmeter持续集成笔记(五:问题优化)
通过前面的一系列文章,我的API自动化测试平台已经搭建成型,但是要投入具体项目使用时,还有以下几个问题需要优化. 还是接着以上一篇笔记中的“test_token”项目为例: 1.邮件通知问题 (1)问 ...
- 白话skynet第二篇:skynet的通信调试pack和sprotol
今天来说说Skynet客户端和服务端网络通信的基础部分. Skynet当前版本.lua是skynet自带的5.3版本. 根据示例,我们可以知道.通信的步骤如下. 客户端按大小端打包成二进制. sock ...
- 23.C# 语言的改进
1.对象初始化器 class Curry { public string MainIngredient{get;set;} public string Style { get; set; } publ ...