Universal Cup Judging System

Universal Cup

Time Limit: 4 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show]
統計

给你 $n$ 个二维欧氏平面上的点,这些点中编号相邻的两个点进行连边,构成一个简单多边形,你需要进行 $q$ 次询问。

一个多边形是简单多边形,当且仅当其所有结点都不同,并且对该简单多边形的任意两条边,都不会发生相交或者在某点接触,除非这两条边在多边形上是相邻的两条边,这种情况下两条边可以在结点处相交。保证相邻的两条边不会共线。

对每个询问,给定两个点 $P$ 和 $Q$,你需要判断线段 $PQ$ 是否和该简单多边形相交。注意到如果线段恰好经过该简单多边形上的某个点,你也需要回答是。

输入格式

第一行包含两个数 $n$ 和 $q$,表示点的个数和询问的个数。

之后的 $n$ 行,每行包含两个整数 $x$ 和 $y$,表示简单多边形上的一个点 $(x,y)$。所有多边形上的点要么是顺时针顺序给出,要么是逆时针顺序给出。

接下来 $q$ 行每行包含四个整数 $x_1,y_1,x_2$ 和 $y_2$,表示查询的两个端点 $P(x_1,y_1)$ 和 $Q(x_2,y_2)$。保证所有给定的询问的所有端点都互不相同。

输出格式

对每个询问,输出一行一个字符串表示答案。

如果该线段和简单多边形有交,则输出 YES,否则输出 NO

样例数据

样例 1 输入

4 6
1 1
4 1
4 4
1 4
0 2 2 0
0 1 1 1
0 0 5 5
2 2 4 2
2 2 3 2
5 1 0 2

样例 1 输出

YES
YES
YES
YES
NO
YES

子任务

Idea:Claris,Solution:Claris,Code:Claris,Data:Claris

对于 $100\%$ 的数据,满足 $3 \leq n\leq 2\times 10^5$, $1\leq q\leq 2\times 10^5$,$0\leq x,y\leq 3\times 10^4$,$0\leq x_1,y_1,x_2,y_2\leq 3\times 10^4$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.