結果
| 問題 |
No.3225 2×2行列相似判定 〜easy〜
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-08 21:40:35 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,793 bytes |
| コンパイル時間 | 992 ms |
| コンパイル使用メモリ | 93,820 KB |
| 実行使用メモリ | 10,912 KB |
| 最終ジャッジ日時 | 2025-08-08 21:40:40 |
| 合計ジャッジ時間 | 4,742 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 TLE * 1 -- * 1 |
| other | -- * 33 |
ソースコード
/*
def dot(A, B):
C = [[None for col in range(2)] for row in range(2)]
for row in range(2):
for col in range(2):
# C[row][col]:= Aのrow行目とBのcol列目の内積
tmp = 0
for i in range(2):
tmp += A[row][i] * B[i][col]
C[row][col] = tmp
return C
A = [list(map(int, input().split())) for row in range(2)]
B = [list(map(int, input().split())) for row in range(2)]
for a in range(67):
for b in range(67):
for c in range(67):
for d in range(67):
P = [[a, b], [c, d]]
PA = dot(P, A)
BP = dot(B, P)
if (PA[0][0]%67 == BP[0][0]%67) and (PA[0][1]%67 == BP[0][1]%67) and (PA[1][0]%67 == BP[1][0]%67) and (PA[1][1]%67 == BP[1][1]%67):
if (a*d - b*c) % 67 != 0:
print("Yes")
exit()
print("No")
*/
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> dot(const vector<vector<int>>& A, const vector<vector<int>>& B) {
vector<vector<int>> C(2, vector<int>(2));
for (int row = 0; row < 2; ++row) {
for (int col = 0; col < 2; ++col) {
int tmp = 0;
for (int i = 0; i < 2; ++i) {
tmp += A[row][i] * B[i][col];
}
C[row][col] = tmp;
}
}
return C;
}
int main() {
vector<vector<int>> A(2, vector<int>(2));
vector<vector<int>> B(2, vector<int>(2));
for (int row = 0; row < 2; ++row) {
for (int col = 0; col < 2; ++col) {
cin >> A[row][col];
}
}
for (int row = 0; row < 2; ++row) {
for (int col = 0; col < 2; ++col) {
cin >> B[row][col];
}
}
for (int a = 0; a < 67; ++a) {
for (int b = 0; b < 67; ++b) {
for (int c = 0; c < 67; ++c) {
for (int d = 0; d < 67; ++d) {
vector<vector<int>> P = {{a, b}, {c, d}};
vector<vector<int>> PA = dot(P, A);
vector<vector<int>> BP = dot(B, P);
if ((PA[0][0] % 67 == BP[0][0] % 67) &&
(PA[0][1] % 67 == BP[0][1] % 67) &&
(PA[1][0] % 67 == BP[1][0] % 67) &&
(PA[1][1] % 67 == BP[1][1] % 67)) {
if ((a * d - b * c) % 67 != 0) {
cout << "Yes" << endl;
return 0;
}
}
}
}
}
}
cout << "No" << endl;
return 0;
}