結果

問題 No.3225 2×2行列相似判定 〜easy〜
ユーザー ooaiu
提出日時 2025-09-13 12:56:34
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 1,129 bytes
コンパイル時間 3,002 ms
コンパイル使用メモリ 276,568 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-13 12:56:45
合計ジャッジ時間 10,346 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    using S = array<ll, 4>;
    S A, B;
    for (int i = 0; i < 4; i++) cin >> A[i];
    for (int i = 0; i < 4; i++) cin >> B[i];
    const int P = 67;
    auto f = [&](const S& a, const S& b) {
        S e{};
        e[0] = a[0] * b[0] + a[1] * b[2];
        e[1] = a[0] * b[1] + a[1] * b[3];
        e[2] = a[2] * b[0] + a[3] * b[2];
        e[3] = a[2] * b[1] + a[3] * b[3];
        for (int i = 0; i < 4; i++) e[i] %= P;
        return e;
    };
    for (int i = 0; i < P; i++) {
        for (int j = 0; j < P; j++) {
            for (int k = 0; k < P; k++) {
                for (int l = 0; l < P; l++) {
                    if (i * l - j * k == 0) continue;
                    S p{i, j, k, l};
                    auto L = f(p, A);
                    auto R = f(B, p);
                    if (L == R) {
                        cout << "Yes\n";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "No\n";
}
0