QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#8848. 点与线

Statistiques

有一天,你发现了一张写有奇怪文字的古老卷轴。

你发现这些文字实际上是一个表示隐藏宝藏位置的表达式。该表达式由以下三种运算组成:

  • 由两个点,得到经过这两点的直线。
  • 由一个点和一条直线,得到该点关于这条直线的对称点。
  • 由两条直线,得到这两条直线的交点。

该表达式的语法由以下 BNF 范式表示:

<expression> ::= <point>
<point> ::= <point-factor> | <line> "@" <line-factor> | <line> "@" <point-factor> | <point> "@" <line-factor>
<point-factor> ::= "(" <number> "," <number> ")" | "(" <point> ")"
<line> ::= <line-factor> | <point> "@" <point-factor>
<line-factor> ::= "(" <line> ")"
<number> ::= <zero-digit> | <positive-number> | <negative-number>
<positive-number> ::= <nonzero-digit> | <positive-number> <digit>
<negative-number> ::= "-" <positive-number>
<digit> ::= <zero-digit> | <nonzero-digit>
<zero-digit> ::= "0"
<nonzero-digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

每个 <point><point-factor> 表示一个点,而每个 <line><line-factor> 表示一条直线。前一种 <point-factor> 的形式 $(X, Y)$ 表示二维平面上横坐标为 $X$、纵坐标为 $Y$ 的点。“@”表示对两个操作数进行的运算。由于每种运算都可以根据其操作数的类型(即点或直线)来区分,因此所有这些运算都用同一个字符“@”表示。注意,从 BNF 可以看出,“@”是左结合的。

你的任务是确定宝藏的位置。

输入格式

输入包含多组数据。每组数据为一行,包含一个表示宝藏位置的表达式。

保证每组数据满足以下条件:

  • 字符串长度不超过 $10^2$。
  • 如果“@”的两个操作数都是点,则它们的距离大于 $1$。
  • 如果“@”的两个操作数都是直线,则它们永不平行。
  • 在计算过程中的任何时刻,点的坐标绝对值不超过 $10^2$。

你可以假设最多有 $100$ 组数据。 输入以仅包含一个“#”的行结束。

输出格式

对于每组数据,按顺序输出该表达式所表示点的 $X$ 和 $Y$ 坐标。 如果输出的绝对误差或相对误差不超过 $10^{-2}$,则视为正确。

样例

输入 1

((0,0)@(1,1))@((4,1)@(2,5))
((0,0)@(3,1))@((1,-3)@(2,-1))
(0,0)@(1,1)@(4,1)
(0,0)@((1,1)@(4,1))
(((0,0)@((10,20)@(((30,40))))))
((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)
#

输出 1

3.00000000 3.00000000
3.00000000 1.00000000
1.00000000 4.00000000
0.00000000 2.00000000
-10.00000000 10.00000000
-99.83681795 -91.92248853

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.