結果
問題 |
No.3231 2×2行列相似判定 〜hard〜
|
ユーザー |
|
提出日時 | 2025-08-08 23:20:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,651 bytes |
コンパイル時間 | 4,602 ms |
コンパイル使用メモリ | 255,204 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-08-08 23:20:44 |
合計ジャッジ時間 | 4,692 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 WA * 4 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; using mint = atcoder::modint1000000007; int main(){ ios::sync_with_stdio(false); cin.tie(0); array<array<mint,2>,2> A, B; int v; for(int y = 0; y < 2; y++){ for(int x = 0; x < 2; x++){ cin >> v; A[y][x] = v; } } for(int y = 0; y < 2; y++){ for(int x = 0; x < 2; x++){ cin >> v; B[y][x] = v; } } vector<vector<mint>> C = { {A[0][0] - B[0][0], A[1][0], -B[0][1], 0}, {A[0][1], A[1][1] - B[0][0], 0, -B[0][1]}, {-B[1][0], 0, A[0][0] - B[1][1], A[1][0]}, {0, -B[1][0], A[0][1], A[1][1] - B[1][1]}, }; int rank = 0; constexpr int N = 4; for(int col = 0; col < N; col++){ int pivot = -1; for(int y = rank; y < N; y++){ if(C[y][col] != 0){ pivot = y; break; } } if(pivot == -1) continue; swap(C[rank], C[pivot]); mint div = C[rank][col].inv(); for(int x = col; x < N; x++) C[rank][x] *= div; for(int y = 0; y < N; y++){ if(y == rank || C[y][rank] == 0) continue; mint coef = C[y][rank]; for(int x = col; x < N; x++){ C[y][x] -= coef * C[rank][x]; } } rank++; } int res = 0; for(int y = 0; y < rank; y++){ if(accumulate(C[y].begin(), C[y].end(), mint(0)) != 1){ res++; } } if(res >= 2){ cout << "Yes\n"; }else{ cout << "No\n"; } }