QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#12014. 简单计算几何题

统计

有 $n$ 个线段。第 $i$ 条线段连接 $(a_i,b_i),(c_i,d_i)$。同时这些直线满足如下性质:

  • 对于任意线段,满足 $c_i > a_i , d_i < b_i$
  • 对于任意两条线段,其不包含任何公共点(包括端点在内)。

$Q$ 次询问,每次询问给出一个点 $(x_i,y_i)$ 。询问对于所有 $n$ 条线段,其落在以 $(-C,-C)$ 为左下角,$(x_i,y_i)$ 为右上角的矩形内的部分的长度之和。

输入格式

第一行一个正整数 $n$。

接下来 $n$ 行,每行四个整数 $a_i,b_i,c_i,d_i$。

接下来一行一个正整数 $Q$。

接下来 $Q$ 行,一行两个整数 $x_i,y_i$。

输出格式

$Q$ 行,一行一个非负实数,表示答案。

假定输入的所有的线段长度之和为 $S$, 你的答案被认为是正确的当且仅当对于每次询问,你和标准输入的绝对误差不超过 $10^{-10}\max \{S,1\}$。换而言之,假设你的输出是 $a$,标准答案是 $b$,则你的答案被认为是正确的当且仅当 $|a-b| \le 10^{-10}\max \{S,1\}$。

样例数据

样例 1 输入

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

样例 1 输出

0.0000000000
4.6312027626
5.2321279752

样例 2 输入

5
1 2 2 1
0 3 1 1
0 4 2 -1
0 2 1 -5
1 3 5 1
5
-300000 -300000
300000 300000
1 3
2 1
1 2

样例 2 输出

0.0000000000
20.5786501139
10.9226852318
8.2149811903
8.7276182816

子任务

  • Subtask 1: $n,Q \le 50$ ($8 \%$)
  • Subtask 2: $n,Q \le 5000$ ($10 \%$)
  • Subtask 3: 线段长度之和不超过 $10^6$ ($22 \%$)
  • Subtask 4: 对于所有的线段,满足 $a_i+b_i = c_i+d_i$ ($15 \%$)
  • Subtask 5: 没特殊限制 ($45 \%$)

对于所有测试数据,满足 $C = 3 \times 10^5, |a_i|,|b_i|,|c_i|,|d_i|,|x_i|,|y_i| \le 3 \times 10^5, n \le 1 \times 10^5,Q \le 1.5 \times 10^5$。

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.