結果
問題 | No.471 直列回転機 |
ユーザー | kyuna |
提出日時 | 2019-09-24 12:19:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,419 bytes |
コンパイル時間 | 1,085 ms |
コンパイル使用メモリ | 80,388 KB |
実行使用メモリ | 25,592 KB |
平均クエリ数 | 19588.39 |
最終ジャッジ日時 | 2024-07-16 18:10:31 |
合計ジャッジ時間 | 25,247 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 27 ms
24,800 KB |
testcase_07 | AC | 32 ms
25,196 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 550 ms
24,836 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 24 ms
25,196 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 439 ms
25,208 KB |
testcase_24 | AC | 251 ms
24,824 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 233 ms
24,568 KB |
testcase_28 | WA | - |
testcase_29 | AC | 328 ms
24,952 KB |
testcase_30 | WA | - |
testcase_31 | AC | 495 ms
24,824 KB |
testcase_32 | AC | 428 ms
24,568 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 101 ms
25,208 KB |
testcase_39 | WA | - |
testcase_40 | AC | 376 ms
24,568 KB |
testcase_41 | AC | 522 ms
24,568 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 62 ms
25,208 KB |
testcase_45 | AC | 313 ms
25,080 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; } template<class T> struct Matrix { vector<vector<T>> val; Matrix(int n = 1, int m = 1, T x = 0) { val.assign(n, vector<T>(m, x)); } size_t size() const { return val.size(); } vector<T>& operator[](int i) { return val[i]; } const vector<T>& operator[](int i) const { return val[i]; } friend ostream& operator<<(ostream& os, const Matrix<T> M) { for (int i = 0; i < M.size(); ++i) os << M[i] << " \n"[i != M.size() - 1]; return os; } }; template<class T> Matrix<T> operator^(Matrix<T> A, long long n) { Matrix<T> R(A.size(), A.size()); for (int i = 0; i < A.size(); ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } template<class T> Matrix<T> operator*(const Matrix<T>& A, const Matrix<T>& B) { Matrix<T> R(A.size(), B[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < B[0].size(); ++j) for (int k = 0; k < B.size(); ++k) R[i][j] += A[i][k] * B[k][j]; return R; } template<class T> vector<T> operator*(const Matrix<T> &A, vector<T> &B) { vector<T> v(A.size()); for (int i = 0; i < A.size(); ++i) for (int k = 0; k < B.size(); ++k) v[i] += A[i][k] * B[k]; return v; } template<class T> Matrix<T> operator+(const Matrix<T>& A, const Matrix<T>& B) { Matrix<T> R(A.size(), A[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) R[i][j] = A[i][j] + B[i][j]; return R; } template<class T> T affine2(T a, T b, long long n, T x1 = 1) { Matrix<T> A(2, 2); A[0][0] = a; A[0][1] = b; // x[k + 1] = a * x[k] + b A[1][0] = 0; A[1][1] = 1; auto pow = A ^ (n - 1); return pow[0][0] * x1 + pow[0][1]; } template<class T> Matrix<T> affine2D(T p = T(1), T q = T(0), T r = T(0), T s = T(1), T b1 = T(0), T b2 = T(0)) { Matrix<T> A(3, 3); A[0][0] = p; A[0][1] = q; A[0][2] = b1; // ⎛y1⎞ ⎛p q⎞ ⎛x1⎞ ⎛b1⎞ A[1][0] = r; A[1][1] = s; A[1][2] = b2; // ⎝y2⎠ = ⎝r s⎠ ⎝x2⎠ * ⎝b2⎠ A[2][0] = 0; A[2][1] = 0; A[2][2] = 1; return A; } template<class T> Matrix<T> rot(T theta) { return affine2D(cos(theta), -sin(theta), sin(theta), cos(theta), 0, 0); } template<class T> Matrix<T> rot_cw90() { return affine2D(T(0), T(1), -T(1), T(0), T(0), T(0)); } template<class T> Matrix<T> rot_ccw90() { return affine2D(T(0), -T(1), T(1), T(0), T(0), T(0)); } template<class T> Matrix<T> trans(T b1, T b2) { return affine2D(T(1), T(0), T(0), T(1), b1, b2); } int main() { int n; cin >> n; vector<vector<int>> p(n, vector<int>(3, 1)); for (int i = 0; i < n; i++) cin >> p[i][0] >> p[i][1]; cout << "? 0 0" << endl; int dx, dy; cin >> dx >> dy; cout << "? 1 0" << endl; int cos, sin; cin >> cos >> sin; cos -= dx, sin -= dy; Matrix<int> affine = trans<int>(dx, dy); if (cos == -1) affine = affine + rot_cw90<int>() * rot_cw90<int>(); if (sin == 1) affine = affine + rot_ccw90<int>(); if (sin == -1) affine = affine + rot_cw90<int>(); cout << "!" << endl; for (int i = 0; i < n; i++) { auto res = affine * p[i]; cout << res[0] << " " << res[1] << endl; } return 0; }