結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-10-22 15:50:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 1,838 bytes |
| コンパイル時間 | 1,488 ms |
| コンパイル使用メモリ | 159,752 KB |
| 実行使用メモリ | 19,384 KB |
| 最終ジャッジ日時 | 2025-10-22 15:50:09 |
| 合計ジャッジ時間 | 3,904 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define int ll
const int N = 100000 + 100;
const int inf = 1e9 + 7;
using namespace std;
inline int read () {
int x = 0, k = 1; char c = getchar();
while (c < '0' || c > '9') { if (c == '-') k = -1; c = getchar(); }
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
return x * k;
}
const int M = 4;
struct Matrix {
// thk sysulby.
int r, c, a[M][M];
Matrix (int r = 3, int c = 3, int p = 0): r(r), c(c) { memset(a, 0, sizeof(a)); for (int i = 0; i < r && i < c; ++i) a[i][i] = p; }
int* operator[] (int i) { return a[i]; }
const int* operator[] (int i) const { return a[i]; }
Matrix operator + (const Matrix &m) const { Matrix ret(r, c); for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j) ret[i][j] = (a[i][j] + m[i][j]); return ret; }
Matrix operator * (const Matrix &m) const { Matrix ret(r, m.c); for (int i = 0; i < r; ++i) for (int j = 0; j < m.c; ++j) for (int k = 0; k < c; ++k) ret[i][j] = (ret[i][j] + a[i][k] * m[k][j]); return ret; }
Matrix pow (int b) { Matrix a = *this, ret(r, r, 1); while (b) { if (b & 1) ret = ret * a; a = a * a, b >>= 1; } return ret; }
};
int n, Px, Py, x[N], y[N];
Matrix a[N]; Matrix O(3, 3, 1);
signed main() {
// freopen("Test.in", "r", stdin);
// freopen("Test.out", "w", stdout);
n = read(), Px = read(), Py = read();
for (int i = 1; i <= n; ++i) {
int o = read(), d = (o == 3) ? (0) : read();
if (o == 1) a[i] = O, a[i][0][2] = d;
if (o == 2) a[i] = O, a[i][1][2] = d;
if (o == 3) a[i][0][1] = 1, a[i][1][0] = -1, a[i][2][2] = 1;
}
for (int i = n; i >= 1; --i) O = O * a[i], x[i] = O[0][0] * Px + O[0][1] * Py + O[0][2], y[i] = O[1][0] * Px + O[1][1] * Py + O[1][2];
for (int i = 1; i <= n; ++i) printf("%lld %lld\n", x[i], y[i]);
return 0;
}
/*
*/
vjudge1