結果
問題 |
No.3225 2×2行列相似判定 〜easy〜
|
ユーザー |
|
提出日時 | 2025-08-08 21:44:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 176 ms / 2,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 3,573 ms |
コンパイル使用メモリ | 320,796 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-08 21:44:11 |
合計ジャッジ時間 | 7,162 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> static inline constexpr std::array<std::array<uint_fast32_t, 2>, 2> mul(const std::array<std::array<uint_fast32_t, 2>, 2>& a, const std::array<std::array<uint_fast32_t, 2>, 2>& b, const uint_fast32_t p) noexcept { std::array<std::array<uint_fast32_t, 2>, 2> result = { { 0, } }; for (uint_fast32_t i = 0; i != 2; ++i) for (uint_fast32_t j = 0; j != 2; ++j) result[i][j] = (a[i][0] * b[0][j] + a[i][1] * b[1][j]) % p; return result; } static inline constexpr bool solve(const std::array<std::array<std::array<uint_fast32_t, 2>, 2>, 2>& M) noexcept { constexpr uint_fast32_t p = 67; std::array<std::array<uint_fast32_t, 2>, 2> P = { std::array<uint_fast32_t, 2>{ 0, 0 }, std::array<uint_fast32_t, 2>{ 0, 0 } }; for (P[0][0] = 0; P[0][0] != p; ++P[0][0]) for (P[0][1] = 0; P[0][1] != p; ++P[0][1]) for (P[1][0] = 0; P[1][0] != p; ++P[1][0]) for (P[1][1] = 0; P[1][1] != p; ++P[1][1]) if (P[0][0] * P[1][1] != P[0][1] * P[1][0] && mul(P, M[0], p) == mul(M[1], P, p)) return true; return false; } static inline void output(const bool ans) noexcept { if (ans) std::cout << "Yes\n"; else std::cout << "No\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::array<std::array<std::array<uint_fast32_t, 2>, 2>, 2> M; uint_fast32_t i, j, k; for (i = 0; i != 2; ++i) for (j = 0; j != 2; ++j) for (k = 0; k != 2; ++k) std::cin >> M[i][j][k]; output(solve(M)); return 0; }