Title:
solution:
1.顺时针旋转90度:
(x,y)->(y,-x)
2.逆时针旋转90度:
(x,y)->(-y,x)
3.关于x=p对称:
(x,y)->(2p-x,y)
4.关于y=p对称:
(x,y)->(x,2p-y)
可以推出以下矩阵,维护以下矩阵前缀积即可.
code:
#include <bits/stdc++.h>
#define int long long
#define PI pair<int,int>
using namespace std;
const int maxm=2e6+5;
struct Mat{
int a[3][3];
void init(){
memset(a,0,sizeof a);
}
Mat operator*(const Mat& x){
Mat ans;ans.init();
for(int k=0;k<3;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
ans.a[i][j]+=a[i][k]*x.a[k][j];
}
}
}
return ans;
}
};
int x[maxm],y[maxm];
Mat T[maxm];
int n,m,q;
void solve(){
cin>>n;
for(int i=1;i<=n;i++)cin>>x[i]>>y[i];
cin>>m;
T[0]={
1,0,0,0,1,0,0,0,1};//T[0]是单位矩阵
for(int i=1;i<=m;i++){
int op;cin>>op;
Mat t;
if(op==1){
//顺时针旋转90度
t={
0,1,0,-1,0,0,0,0,1};
}else if(op==2){
//逆时针旋转90度
t={
0,-1,0,1,0,0,0,0,1};
}else if(op==3){
//关于x=p对称
int p;cin>>p;
t={
-1,0,2*p,0,1,0,0,0,1};
}else if(op==4){
//关于y=p对称
int p;cin>>p;
t={
1,0,0,0,-1,2*p,0,0,1};
}
T[i]=t*T[i-1];
}
cin>>q;
for(int i=1;i<=q;i++){
int a,b;cin>>a>>b;
Mat t={
x[b],0,0,y[b],0,0,1,0,0};
t=T[a]*t;
cout<<t.a[0][0]<<' '<<t.a[1][0]<<endl;
}
}
signed main(){
ios::sync_with_stdio(0);
solve();
return 0;
}