QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 1024 MB Total points: 100

#5174. 青蛙思直线

Statistics

题目描述

在寒风呼啸的雾之湖,琪露诺正在追逐一只青蛙。

这只青蛙将依次进行 $n$ 个操作:跳过一条直线,起跳点与着落点关于直线对称;或绕一点旋转跳若干角度。

琪露诺将要施加 $q$ 个魔法。

A 冻符「Perfect Freeze」魔法 询问在某一点放一只青蛙跳过一个区间的直线和点后会在哪里。

B 冰块「Great Crusher」魔法 可以让区间内所有直线和点关于给定直线对称。

C 雹符「Hailstorm」魔法 可以让区间内所有直线和点绕一点旋转若干角度。

琪露诺的数学实在太好了,以至于无法清晰地描述这些操作。所以,她让八云蓝做了一份形式化体面放在后面。

总之,请你预测每个A魔法青蛙最后的位置,因为琪露诺无法理解⑨以上的数字,所以只要对 $998244353$ 取模糊弄她一下就好了。

解析几何中有一些对称和旋转的操作。

为了清楚地描述这两种变换,我们定义函数 $f(A,B)$。其中 $A$ 为一个二元组表示点的坐标 $(x,y)$,$B$ 为一个三元组或一个五元组。

如果 $B$ 为三元组 $(a,b,c)$ 则 $f(A,B)$ 返回 $(x,y)$ 关于直线 $ax+by+c=0$ 的对称点

如果 $B$ 为五元组 $(x_0,y_0,a,b,c)$ 则 $f(A,B)$ 返回 $(x,y)$ 绕点 $(x_0,y_0)$ 逆时针旋转 $\theta$ 后的坐标,其中 $\sin\theta=\frac ac,\cos\theta=\frac bc$,保证 $a^2+b^2=c^2$。

解析几何中还有直线关于直线对称这样的操作。为了描述这种操作,我们定义 $g(A,B)$:

如果 $A$ 为五元组 $(x_0,y_0,a,b,c)$,则计算 $(x_0',y_0')=f((x_0,y_0),B)$,并返回新的五元组 $(x_0',y_0',a,b,c)$。

如果 $A$ 为三元组 $(a,b,c)$,则返回一组 $(a',b',c')$ 满足 $\{(x,y)|a'x+b'y+c'=0\}=\{f((x,y),B)|ax+by+c=0\}$。可以证明这样的 $a',b',c'$ 总是存在的。

现在有一个长度为 $n$ 的序列 $A_i$,每个元素为三元组或五元组。有三种操作:

给定 $x,y,l,r$,询问 $f(f(\dots f((x,y),A_l)\dots,A_{r-1}),A_r)$。

给定 $a,b,c,l,r$,把 $l\le i\le r$ 的 $A_i$ 变成 $g(A_i,(a,b,c))$。

给定 $x_0,y_0,a,b,c,l,r$,把 $l\le i\le r$ 的 $A_i$ 变成 $g(A_i,(x_0,y_0,a,b,c))$。

由于解析几何总是要求精确解但是计算机有精度限制,你只需要输出对 $998244353$ 取模的结果进行验算即可。

可以证明答案一定是有理数。

输入格式

第一行两个整数 $n,q$。

接下来 $n$ 行,每行首先有一个整数 $op$。

如果 $op=1$,则输入一个三元组 $(a,b,c)$,否则如果 $op=2$ 输入一个五元组 $(x_0,y_0,a,b,c)$。

接下来 $q$ 行,每行首先有一个整数 $op$。

如果 $op=1$,则输入四个整数 $x,y,l,r$,如果 $op=2$,输入一个三元组 $(a,b,c)$ 和两个整数 $l,r$,否则如果 $op=3$ 则输入一个五元组 $(x_0,y_0,a,b,c)$ 和两个整数 $l,r$。

输出格式

对于每个操作1输出最终的点的坐标对 $998244353$ 取模的结果。

样例 #1

样例输入 #1

2 8
1 1 -1 0
2 1 1 3 4 5
1 1 6 1 1
1 1 6 2 2
2 1 0 0 1 2
1 -1 6 1 1
1 -1 6 2 2
3 0 0 1 0 1 1 2
1 -1 4 1 1
1 -1 4 2 2

样例输出 #1

6 1
998244351 5
998244347 1
998244349 5
4 998244352
998244349 3

提示

对于 $100\%$ 的数据满足 $1\le n,q\le 10^5$。

任何三元组 $(a,b,c)$ 满足 $-10^9\le a,b,c\le10^9$,$a^2+b^2\not\equiv 0\pmod {998244353}$。

任何五元组 $(x_0,y_0,a,b,c)$ 满足 $-10^9\le x_0,y_0,a,b,c\le10^9,c\not\equiv0\pmod{998244353}$,$a^2+b^2=c^2$。

子任务编号 分数 $n,q\le$ 特殊性质
$1$ $10$ $100$ $ $
$2$ $10^3$
$3$ $15$ $10^5$ 输入没有五元组
$4$ 输入没有三元组
$5$ 所有询问 $op=1$
$6$ $35$ $ $

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.