結果
問題 |
No.675 ドットちゃんたち
|
ユーザー |
![]() |
提出日時 | 2018-04-14 17:46:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 1,199 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 76,652 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 22:27:21 |
合計ジャッジ時間 | 2,411 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; struct P { int x, y, r; }; void rot(int& x, int& y, int r) { r &= 3; if (r == 0) { return; } else if (r == 1) { int t = x; x = -y; y = t; } else if (r == 2) { x = -x; y = -y; } else if (r == 3) { int t = x; x = y; y = -t; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, px, py; cin >> n >> px >> py; vector<P> p(n + 1); p[0] = { 0, 0, 0 }; int x = 0, y = 0, r = 0; for (int i = 0; i < n; i++) { int c; cin >> c; if (c != 3) { int d[2] = {}; cin >> d[c == 2]; rot(d[0], d[1], r); x += d[0]; y += d[1]; } else { r++; } p[i + 1] = { x, y, r }; } for (int i = 0; i < n; i++) { int x = px, y = py; rot(x, y, p[i].r); x += p[n].x - p[i].x; y += p[n].y - p[i].y; rot(x, y, -p[n].r); cout << x << ' ' << y << '\n'; } return 0; }