Luogu P2129 L国的战斗续之多路出击 模拟
诡异而冗长的名字下一般没什么难题
坐标的本质是与原点的相对位置关系,所以改变全部坐标只要改变坐标系就好了。
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 typedef long long ll; 5 6 const ll Maxn = 5e5+10; 7 8 ll x[Maxn],y[Maxn],ox,oy,xt,yt,n,m,p[Maxn],q[Maxn]; 9 char opt[Maxn]; 10 11 void read(ll& a){ 12 a = 0;char c = getchar(),l = c; 13 while(c < '0'||c > '9')l = c,c = getchar(); 14 while('0' <= c&&c <= '9')a = a*10+c-'0',c = getchar(); 15 if(l == '-')a = -a; 16 } 17 18 void read(ll& a,ll& b){ 19 read(a),read(b); 20 } 21 22 int main(){ 23 xt = yt = 1,ox = oy = 0; 24 read(n,m); 25 for(ll i = 1;i <= n;i++)read(x[i],y[i]); 26 for(int i = 1;i <= m;i++){ 27 cin >> opt[i]; 28 if(opt[i] == 'm')read(p[i],q[i]); 29 } 30 while(m){ 31 if(opt[m] == 'x')xt = -xt; 32 else if(opt[m] == 'y')yt = -yt; 33 else ox -= xt*p[m],oy -= yt*q[m]; 34 m--; 35 } 36 for(ll i = 1;i <= n;i++)printf("%lld %lld\n",xt*(x[i]-ox),yt*(y[i]-oy)); 37 return 0; 38 }