結果

問題 No.3225 2×2行列相似判定 〜easy〜
ユーザー Carpenters-Cat
提出日時 2025-08-11 04:47:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 201,444 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-08-11 04:47:40
合計ジャッジ時間 3,229 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using vc = std::vector<int> ;
using mat = vector<vc>;
mat prod(const mat& A, const mat& B) {
	mat ret(A.size(), vc(B[0].size()));
	for (int i = 0; i < A.size(); i ++) {
		for (int j = 0; j < B[0].size(); j ++) {
			ret[i][j] = 0;
			for (int k = 0; k < A[0].size(); k ++) {
				ret[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	return ret;
}
int main () {
	mat A(2, vc(2)), B(2, vc(2));
	for (auto& a : A) {
		for (auto& b : a) {
			cin >> b;
		}
	}
	for (auto& a : A) {
		for (auto& b : a) {
			cin >> b;
		}
	}
	int p = 67;
	mat P = {{0, 0}, {0, 0}};
	for (;P[0][0] < p; P[0][0] ++) {
		for (;P[0][1] < p; P[0][1] ++) {
			for (;P[1][0] < p; P[1][0] ++) {
				for (;P[1][1] < p; P[1][1] ++) {
					auto ap = prod(P, A);
					auto pb = prod(B, P);
					bool ok = true;
					for (int i = 0; i < 2; i ++) {
						for (int j = 0; j < 2; j ++) {
							ok = ok && (ap[i][j] % p == pb[i][j]);
						}
					}
					if (ok) {
						puts("Yes");
						return 0;
					}
				}
			}
		}
	}
	puts("No");
}
0