CF358A.Dima and Continuous Line

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.

The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them by semi-circus in a certain order: first connect the first point with the second one, then connect the second point with the third one, then the third one with the fourth one and so on to the n-th point. Two points with coordinates (_x_1, 0) and (_x_2, 0) should be connected by a semi-circle that passes above the abscissa axis with the diameter that coincides with the segment between points. Seryozha needs to find out if the line on the picture intersects itself. For clarifications, see the picture Seryozha showed to Dima (the left picture has self-intersections, the right picture doesn't have any).

Seryozha is not a small boy, so the coordinates of the points can be rather large. Help Dima cope with the problem.

季马和谢廖沙住在一间普通的双人宿舍里。一天,季马要和女友约会,便请谢廖沙暂时离开宿舍。作为补偿,谢廖沙让季马帮他完成作业。

老师给了谢廖沙数轴(即 xx 轴)上 nn 个互不相同的点的坐标,并要求他按特定顺序依次用半圆连接这些点:先连接第一个点与第二个点,再连接第二个点与第三个点,接着连接第三个点与第四个点,依此类推,直至连接第 n−1n-1 个点与第 nn 个点。坐标分别为 (x1, 0)(x_1, 0) 和 (x2, 0)(x_2, 0) 的两点,应以它们之间的线段为直径、在 xx 轴上方作一个半圆来连接。谢廖沙需要判断所画出的折线(由这些半圆组成)是否与自身相交。为便于理解,请参见谢廖沙向季马展示的示意图(左侧图中曲线存在自交,右侧图中则无任何自交):

谢廖沙可不是小孩子,因此这些点的坐标可能非常大。请帮助季马解决这个问题。

输入格式

The first line contains a single integer n (1 ≤ n ≤ 103). The second line contains n distinct integers _x_1, _x_2, ..., x__n ( - 106 ≤ x__i ≤ 106) — the i-th point has coordinates (x__i, 0). The points are not necessarily sorted by their x coordinate.

第一行包含一个整数 nn(1≤n≤1031 \leq n \leq 10^3)。第二行包含 nn 个互不相同的整数 x1, x2, …, xnx_1,\,x_2,\,\dots,\,x_n(−106≤xi≤106-10^6 \leq x_i \leq 10^6)——第 ii 个点的坐标为 (xi, 0)(x_i,\,0)。这些点不一定按其 xx 坐标排序。

输出格式

In the single line print "yes" (without the quotes), if the line has self-intersections. Otherwise, print "no" (without the quotes).

如果该线段存在自交点,则在单行中输出 “yes”(不带引号);否则输出 “no”(不带引号)。

输入输出样例

  • 输入#1

    4
    0 10 5 15

    输出#1

    yes
  • 输入#2

    4
    0 15 5 10

    输出#2

    no

说明/提示

The first test from the statement is on the picture to the left, the second test is on the picture to the right.

题目描述中的第一个测试用例在左侧图片中,第二个测试用例在右侧图片中。

输入解题思路,AI测评打分。不知道怎么写?

首页