CF29A.Spit Problem
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task.
The trajectory of a camel's spit is an arc, i.e. if the camel in position x spits d meters right, he can hit only the camel in position x + d, if such a camel exists.
在贝尔兰动物园中有一个养着骆驼的围栏。众所周知,骆驼喜欢吐唾沫。鲍勃一整天都在观察这些有趣的动物,并在他的笔记本中记录下了每只动物吐唾沫的位置。现在他想知道:动物园中是否存在两只骆驼,它们彼此朝对方吐唾沫?请帮助他解决这个问题。
骆驼吐唾沫的轨迹是一段圆弧,即:若位于位置 x 的骆驼向右吐唾沫 d 米,则它只能击中位于位置 x+d 的骆驼(如果该位置上确实存在一只骆驼)。
输入格式
The first line contains integer n (1 ≤ n ≤ 100) — the amount of camels in the zoo. Each of the following n lines contains two integers x__i and d__i ( - 104 ≤ x__i ≤ 104, 1 ≤ |d__i| ≤ 2·104) — records in Bob's notepad. x__i is a position of the i-th camel, and d__i is a distance at which the i-th camel spitted. Positive values of d__i correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.
第一行包含一个整数 n(1≤n≤100)—— 动物园中骆驼的数量。接下来的 n 行中,每行包含两个整数 xi 和 di(−104≤xi≤104,1≤∣di∣≤2⋅104)—— 这是 Bob 笔记本中的记录。其中 xi 表示第 i 只骆驼的位置,di 表示第 i 只骆驼吐口水的距离。当 di 为正值时,表示向右吐口水;当 di 为负值时,表示向左吐口水。任意两只骆驼的位置均不相同。
输出格式
If there are two camels, which spitted at each other, output YES. Otherwise, output NO.
如果有两只骆驼互相吐唾沫,则输出 YES。否则,输出 NO。
输入输出样例
输入#1
2 0 1 1 -1
输出#1
YES
输入#2
3 0 1 1 1 2 -2
输出#2
NO
输入#3
5 2 -10 3 10 0 5 5 -5 10 1
输出#3
YES
输入解题思路,AI测评打分。不知道怎么写?