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只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- hdfs directory item limit - (dfs.namenode.fs-limits.max-directory-items)
// :: WARN scheduler.TaskSetManager: Lost task , emr-worker-.cluster-, executor ): org.apache.hadoop ...
- 对于EMC DAE、DPE、SPE、SPS的解释
对于EMC DAE.DPE.SPE.SPS的解释: DAE: Disk Array Enclosure 单一的磁盘扩展单元 CX200/CX300/CX400/CX500CX600/CX700 DPE ...
- nregistering JMX-exposed beans
https://blog.csdn.net/yang474231561/article/details/81738632 https://stackoverflow.com/questions/507 ...
- 理解es6 中 arrow function的this
箭头函数相当于定义时候,普通函数.bind(this)箭头函数根本没有自己的this,导致内部的this就是定义时候的外层代码块中的this.外层代码块中的this,则取决于执行时候环境上下文cont ...
- JAVA生成(可执行)Jar包的全面详解说明 [打包][SpringBoot][Eclipse][IDEA][Maven][Gradle][分离][可执行]
辛苦所得,转载还请注明: https://www.cnblogs.com/applerosa/p/9739007.html 得空整理了关于java 开发中,所有打包方式的 一个操作方法, 有基于ID ...
- Android的Service的创建与使用
Service介绍 Service是Android四大组件中与Activity最为相似的组件,它们都代表可执行的程序,区别是:Service一直在后台运行,没有用户界面.使用service要向Acti ...
- JDBC 查询
//查询""SMITH"的empno import java.sql.Connection; import java.sql.DriverManager; import ...
- [转]k8s核心概念
转载自 https://blog.csdn.net/real_myth/article/details/78719244 什么是kubernetes 首先,他是一个全新的基于容器技术的分布式架构领先方 ...
- VScode 中 vue文件template中不能使用tab补齐标签
选择 文件-->首选项-->设置-->搜索 emmet,选择 编辑 setting.json, 添加下列代码: "emmet.includeLanguages" ...
- AOP代理对象生成
AOP(Aspect-OrientedProgramming,面向方面编程)是OOP(Object-Oriented Programing,面向对象编程)的良好补充与完善,后者侧重于解决 从上到下的存 ...