結果
| 問題 |
No.2255 Determinant Sum
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2023-03-13 17:20:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,237 bytes |
| コンパイル時間 | 1,826 ms |
| コンパイル使用メモリ | 200,144 KB |
| 最終ジャッジ日時 | 2025-02-11 10:56:14 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 4 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
using namespace std;
void solve(){
int n, p; cin >> n >> p;
vector<vector<int>> a(n,vector<int>(n));
rep(i,n) rep(j,n) cin >> a[i][j];
if (p != 2){
cout << 0 << endl;
return ;
}
vector<int> rs, cs;
rep(i,n){
int cnt = 0;
rep(j,n){
if (a[i][j] == -1) cnt++;
}
if (cnt >= 2){
cout << 0 << endl;
return ;
}
if (cnt == 0){
rs.emplace_back(i);
}
}
rep(j,n){
int cnt = 0;
rep(i,n){
if (a[i][j] == -1) cnt++;
}
if (cnt >= 2){
cout << 0 << endl;
return ;
}
if (cnt == 0){
cs.emplace_back(j);
}
}
vector<int> bs;
for (int i : rs){
int x = 0;
for (int j : cs){
x <<= 1;
x += a[i][j];
}
for (int b : bs){
x = min(x,x^b);
}
if (x == 0){
cout << 0 << endl;
return ;
}
bs.emplace_back(x);
}
cout << 1 << endl;
}
int main(){
int t; cin >> t;
while(t--) solve();
}
noya2