結果
| 問題 |
No.3225 2×2行列相似判定 〜easy〜
|
| ユーザー |
|
| 提出日時 | 2025-08-11 04:57:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,309 bytes |
| コンパイル時間 | 2,117 ms |
| コンパイル使用メモリ | 205,220 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-11 04:57:40 |
| 合計ジャッジ時間 | 3,374 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 33 |
ソースコード
#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 : B) {
for (auto& b : a) {
cin >> b;
}
}
if (1) {
for (auto& a : A) {
for (auto& b : a) {
cout << b << " ";
}
cout << endl;
}
for (auto& a : B) {
for (auto& b : a) {
cout << b << " ";
}
cout << endl;
}
}
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] % p);
}
}
if (ok) {
puts("Yes");
return 0;
}
}
}
}
}
puts("No");
}