倒搜模拟,矩阵乘法,结束
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn=500005,INF=2000000000; 4 int X[maxn],Y[maxn],a[maxn],b[maxn]; 5 char cmd[maxn]; 6 int n,M,p=0,q=0,curx=1,cury=1; 7 char c; 8 int main() { 9 cin>>n>>M; 10 for(int i=1; i<=n; i++) cin>>X[i]>>Y[i]; 11 for(int i=0; i<M; i++) { 12 c=getchar(); 13 while(c!=‘x‘&&c!=‘m‘&&c!=‘y‘) c=getchar(); 14 cmd[i]=c; 15 if(c==‘m‘) cin>>a[i]>>b[i]; 16 } 17 for(int i=M-1; i>=0; i--) { 18 if(cmd[i]==‘x‘) p=-p,curx=-curx; 19 else if(cmd[i]==‘y‘) q=-q,cury=-cury; 20 else p+=a[i],q+=b[i]; 21 } 22 for(int i=1; i<=n; i++) printf("%d %d\n",X[i]*curx+p,Y[i]*cury+q); 23 return 0; 24 }
原文地址:https://www.cnblogs.com/hahaha2124652975/p/11674798.html
时间: 2024-11-10 13:04:55