結果

問題 No.760 Where am I moved to?
ユーザー PachicobuePachicobue
提出日時 2018-12-08 02:18:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,596 bytes
コンパイル時間 2,854 ms
コンパイル使用メモリ 199,868 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 15:53:26
合計ジャッジ時間 8,162 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ld = long double;
constexpr ld PI = 3.141592653589793238462643383279;
constexpr ld EPS = 1e-10;
using A3 = std::array<ld, 3>;
using M3 = std::array<A3, 3>;
inline ld dot(const A3& a, const A3& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
inline A3 mul(const M3& m, const A3& a) { return A3{dot(m[0], a), dot(m[1], a), dot(m[2], a)}; }
using A2 = std::array<ld, 2>;
using M2 = std::array<A2, 2>;
inline A2 add(const A2& a, const A2& b) { return A2{a[0] + b[0], a[1] + b[1]}; }
inline A2 sub(const A2& a, const A2& b) { return A2{a[0] - b[0], a[1] - b[1]}; }
inline M2 sub(const M2& m1, const M2& m2) { return M2{sub(m1[0], m2[0]), sub(m1[1], m2[1])}; }
inline ld dot(const A2& a, const A2& b) { return a[0] * b[0] + a[1] * b[1]; }
inline A2 mul(const M2& m, const A2& a) { return A2{dot(m[0], a), dot(m[1], a)}; }
inline M2 inv(const M2& m)
{
    const ld det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
    return M2{{{m[1][1] / det, m[0][1] / (-det)}, {m[1][0] / (-det), m[0][0] / det}}};
}
inline M2 mul(const M2& m1, const M2 m2) { return M2{{{m1[0][0] * m2[0][0] + m1[0][1] * m2[1][0], m1[0][0] * m2[0][1] + m1[0][1] * m2[1][1]}, {m1[1][0] * m2[0][0] + m1[1][1] * m2[1][0], m1[1][0] * m2[0][1] + m1[1][1] * m2[1][1]}}}; }
constexpr M2 U2{{{1, 0}, {0, 1}}};
constexpr M2 Z2{{{0, 0}, {0, 0}}};
int main()
{
    ld xa, ya, ta, x11, y11, x12, y12, u21, v21, u22, v22;
    std::cin >> xa >> ya >> ta >> x11 >> y11 >> x12 >> y12 >> u21 >> v21 >> u22 >> v22, (ta *= PI) /= 180;
    const M3 w2s{{{std::cos(ta), std::sin(ta), -xa * std::cos(ta) - ya * std::sin(ta)}, {-std::sin(ta), std::cos(ta), xa * std::sin(ta) - ya * std::cos(ta)}, {0, 0, 1}}};
    const auto p1 = mul(w2s, A3{u21, v21, 1}), p2 = mul(w2s, A3{u22, v22, 1});
    const ld x21 = p1[0], y21 = p1[1], x22 = p2[0], y22 = p2[1];
    const M2 m1 = {{{x21, -y21}, {y21, x21}}}, m2 = {{{x22, -y22}, {y22, x22}}};
    const M2 m1m2 = inv(sub(m1, m2));
    const M2 m11 = m1m2, m12 = sub(Z2, m1m2), m21 = mul(sub(Z2, m1m2), m2), m22 = mul(m1m2, m1);
    const A2 q1 = A2{x11, y11}, q2 = A2{x12, y12};
    const A2 s1 = add(mul(m11, q1), mul(m12, q2)), s2 = add(mul(m21, q1), mul(m22, q2));
    std::cerr << s1[0] << " " << s1[1] << " " << s2[0] << " " << s2[1] << std::endl;
    const ld norm = std::sqrt(s1[0] * s1[0] + s1[1] * s1[1]);
    ld theta = (std::abs(1 - norm) > EPS ? 0 : s1[1] / norm >= EPS ? std::acos(s1[0] / norm) : 2 * PI - std::acos(s1[0] / norm));
    std::cout << std::fixed << std::setprecision(15) << s2[0] << " " << s2[1] << " " << theta / PI * 180 << std::endl;
    return 0;
}
0