結果
| 問題 |
No.3225 2×2行列相似判定 〜easy〜
|
| ユーザー |
|
| 提出日時 | 2025-08-11 04:48:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,106 bytes |
| コンパイル時間 | 2,048 ms |
| コンパイル使用メモリ | 201,376 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-11 04:48:37 |
| 合計ジャッジ時間 | 2,911 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 15 WA * 18 |
ソースコード
#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] ++) {
if (abs(P[0][0] * P[1][1] - P[1][0] * P[0][1]) % p == 0) continue;
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");
}