結果
問題 | No.675 ドットちゃんたち |
ユーザー | nebukuro09 |
提出日時 | 2018-04-14 00:54:32 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 1,651 bytes |
コンパイル時間 | 825 ms |
コンパイル使用メモリ | 105,344 KB |
実行使用メモリ | 6,892 KB |
最終ジャッジ日時 | 2023-09-03 19:28:21 |
合計ジャッジ時間 | 4,167 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 134 ms
6,680 KB |
testcase_06 | AC | 148 ms
6,688 KB |
testcase_07 | AC | 132 ms
6,484 KB |
testcase_08 | AC | 139 ms
6,892 KB |
testcase_09 | AC | 146 ms
6,620 KB |
testcase_10 | AC | 146 ms
6,636 KB |
testcase_11 | AC | 145 ms
6,636 KB |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; void main() { alias Point = Tuple!(long, "x", long, "y"); auto s = readln.split.map!(to!long); auto N = s[0].to!int; auto S = Point(s[1], s[2]); auto Q = new Tuple!(long, long)[](N); foreach (i; 0..N) { s = readln.split.map!(to!long); long x = s[0] == 3 ? 0 : s[1]; Q[i] = tuple(s[0], x); } Point[] ans; auto M = new long[][](3, 3); foreach (i; 0..3) M[i][i] = 1; auto move = new long[][](3, 3); foreach (i; 0..3) move[i][i] = 1; auto rot = new long[][](3, 3); rot[0][1] = 1; rot[1][0] = -1; rot[2][2] = 1; foreach_reverse (q; Q) { if (q[0] == 1) { move[0][2] = q[1]; M = matmul(3, M, move); move[0][2] = 0; } else if (q[0] == 2) { move[1][2] = q[1]; M = matmul(3, M, move); move[1][2] = 0; } else { M = matmul(3, M, rot); } auto x = M[0][0] * S.x + M[0][1] * S.y + M[0][2]; auto y = M[1][0] * S.x + M[1][1] * S.y + M[1][2]; ans ~= Point(x, y); } foreach_reverse (a; ans) { writeln(a.x, " ", a.y); } } long[][] matmul(int N, long[][] m1, long[][] m2) { auto ret = new long[][](N, N); foreach (i; 0..N) { foreach (j; 0..N) { ret[i][j] = 0; foreach (k; 0..N) { ret[i][j] += m1[i][k] * m2[k][j]; } } } return ret; }