1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #include <bits/stdc++.h> #define int long long
using namespace std;
#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;
int n, m, q; int revx, revy; int addx, addy; int swapxy; array<int, MAXN> x, y, a, b; array<int, MAXN> op, p, ansx, ansy; vector<pair<int, int>> vec[MAXN];
signed main() { boost; cin >> n; for (int i = 1; i <= n; i++) cin >> x[i] >> y[i]; cin >> m; for (int i = 1; i <= m; i++) { cin >> op[i]; if (op[i] > 2) cin >> p[i]; } cin >> q; for (int i = 1; i <= q; i++) { cin >> a[i] >> b[i]; vec[a[i]].emplace_back(b[i], i); } for (auto& i : vec[0]) { ansx[i.second] = x[i.first]; ansy[i.second] = y[i.first]; } for (int i = 1; i <= m; i++) { if (op[i] == 1) { swapxy ^= 1, revx ^= 1, addx *= -1; swap(revx, revy), swap(addx, addy); } else if (op[i] == 2) { swapxy ^= 1, revy ^= 1, addy *= -1; swap(revx, revy), swap(addx, addy); } else if (op[i] == 3) { revx ^= 1, addx *= -1; addx += p[i] * 2; } else { revy ^= 1, addy *= -1; addy += p[i] * 2; } for (auto& ii : vec[i]) { ansx[ii.second] = x[ii.first]; ansy[ii.second] = y[ii.first]; if (swapxy) swap(ansx[ii.second], ansy[ii.second]); if (revx) ansx[ii.second] *= -1; if (revy) ansy[ii.second] *= -1; ansx[ii.second] += addx; ansy[ii.second] += addy; } } for (int i = 1; i <= q; i++) cout << ansx[i] << " " << ansy[i] << "\n"; return 0; }
|