#abc338e. E - Chords

E - Chords

Score: 500500 points

问题描述

在圆上等间距地放置了 2N2N 个点,从某个特定点开始按顺时针方向编号为 112N2N

圆上还有 NN 条弦,其中第 ii 条弦连接着点 AiA_iBiB_i。保证所有值 A1,,AN,B1,,BNA_1, \dots, A_N, B_1, \dots, B_N 都互不相同。

判断这些弦之间是否存在相交的情况。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are 2N2N points placed at equal intervals on a circle, numbered 11 to 2N2N in a clockwise direction starting from a certain point.

There are also NN chords on the circle, with the ii-th chord connecting points AiA_i and BiB_i. It is guaranteed that all the values A1,,AN,B1,,BNA_1,\dots,A_N,B_1,\dots,B_N are distinct.

Determine whether there is an intersection between the chords.

Constraints

  • 2N2×1052\leq N \leq 2\times 10^5
  • 1Ai,Bi2N1\leq A_i,B_i \leq 2N
  • A1,,AN,B1,,BNA_1,\dots,A_N,B_1,\dots,B_N are all distinct
  • All input values are integers

Input

The input is given from Standard Input in the following format:

NN

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

ANA_N BNB_N

Output

If there is an intersection between the chords, print Yes; otherwise, print No.

Sample Input 1

3
1 3
4 2
5 6

Sample Output 1

Yes

As shown in the figure, chord 11 (the line segment connecting points 11 and 33) and chord 22 (the line segment connecting points 44 and 22) intersect, so print Yes.

Sample Input 2

3
6 1
4 3
2 5

Sample Output 2

No

As shown in the figure, there is no intersection between the chords, so print No.

Sample Input 3

4
2 4
3 7
8 6
5 1

Sample Output 3

Yes

update @ 2024/3/10 01:29:45