QOJ.ac

QOJ

Limite de temps : 4.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#15101. An Experiment in Optics Lab

Statistiques

玛丽亚(Maria)是实验室里的一位科学家。目前,她正在进行关于激光和不同材料折射的实验。她将 $n$ 种材料排成一排。每种材料的长度为 $\ell_i$,折射率为 $r_i$。现在,玛丽亚想要执行以下操作 $q$ 次:

  • 将第 $i$ 个材料替换为另一个材料。
  • 从该排材料的某个点发射激光。给出激光束与地面之间的初始夹角。

为了便于解决本题,我们可以将所有材料建模为垂直条带。激光从 $y = 0$ 且给定的某个 $x$ 处出发。

玛丽亚想知道激光束离开最后一个材料时的点的 $y$ 坐标。

请注意,如果激光束穿过折射率分别为 $r_1$ 和 $r_2$ 的两种材料之间的边界,则激光束与水平线之间的夹角 $\theta_1$ 和 $\theta_2$ 满足关系式 $r_1 \sin \theta_1 = r_2 \sin \theta_2$。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^5$)。

接下来的 $n$ 行包含初始材料的描述。每种材料由两个整数描述 —— 它的长度 $\ell_i$ 和它的折射率 $r_i$ ($1 \le \ell_i \le 1000$, $10^4 \le r_i \le 1.6 \cdot 10^4$)。

下一行包含一个整数 $q$ ($1 \le q \le 10^5$)。

接下来的 $q$ 行包含实验的描述。每行以一个整数 $t$ ($1 \le t \le 2$) 开始。

如果 $t = 1$,则后面跟着三个整数 $id$、$\ell$、$r$ ($1 \le id \le n$, $1 \le \ell \le 1000$, $10^4 \le r \le 1.6 \cdot 10^4$)。这表示玛丽亚想要将第 $id$ 个材料替换为长度为 $\ell$、折射率为 $r$ 的新材料。

如果 $t = 2$,则后面跟着两个整数 $x$ 和 $ang$。这表示玛丽亚想要从点 $(x, 0)$ 处以角度 $ang$ 发射激光,并想知道激光束离开该排最后一个材料时的 $y$ 坐标。保证 $x$ 是非负的,且严格小于所有材料长度的总和。如果起点位于两种材料的边界上,我们假设激光从索引(编号)较大的材料中开始。角度 $ang$ 以秒(角秒)为单位给出,即要将其转换为度,应将其除以 $3600$。保证 $0 \le ang \le 1.08 \cdot 10^5$。

输出格式

对于每个 $t = 2$ 的事件,输出一个实数 —— 问题的答案。当且仅当绝对误差或相对误差不超过 $10^{-6}$ 时,答案才被视为正确。

可以证明,在题目的约束条件下,光束永远不会在两种材料之间的边界上发生全反射(即 $|\sin \theta|$ 永远不会超过 $1$)。

样例

输入样例 1

2
1 10000
2 10000
3
2 0 108000
1 2 5 10000
2 0 108000

输出样例 1

1.73205080756887729390
3.46410161513775458845

输入样例 2

2
10 10000
10 12000
3
2 0 108000
1 2 10 16000
2 0 43200

输出样例 2

10.35699517703731412002
3.43612562272318509829

说明

上图展示了第二个样例。红色(粗实线)表示第一个事件中激光束的轨迹,蓝色(粗虚线)表示第三个事件中激光束的轨迹。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.