ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215029 | #2705. Yet another lights out | nodgd | 100 | 5ms | 1200kb | C++11 | 1.6kb | 2024-11-25 20:21:17 | 2024-11-25 23:09:09 |
answer
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100 + 5;
const int MAX_F = 200 + 5;
int T, N, n, m;
char a[MAX_N][MAX_N], r[MAX_N], c[MAX_N], b[MAX_N][MAX_N];
bitset<MAX_F> f[MAX_F];
int h[MAX_F];
int main() {
for (scanf("%d", &T); T --; ) {
scanf("%d%d", &n, &m), N = n + m;
for (int i = 0; i < n; i ++) {
scanf("%s", a[i]);
for (int j = 0; j < m; j ++) {
a[i][j] = a[i][j] == 'B';
r[i] ^= a[i][j];
c[j] ^= a[i][j];
}
}
for (int i = 0; i < n; i ++) {
f[i][i] = ~m & 1;
f[i][N] = r[i], r[i] = 0;
for (int j = 0; j < m; j ++) {
f[i][n + j] = 1;
}
}
for (int j = 0; j < m; j ++) {
f[n + j][n + j] = ~n & 1;
f[n + j][N] = c[j], c[j] = 0;
for (int i = 0; i < n; i ++) {
f[n + j][i] = 1;
}
}
for (int i = 0; i < N; i ++) h[i] = -1;
for (int i = 0, x = 0, k; i < N && x < N; x ++) {
for (k = i; k < N && !f[k][x]; k ++);
if (k >= N) continue;
if (i != k) swap(f[i], f[k]);
for (k = i + 1; k < N; k ++) {
if (f[k][x]) f[k] ^= f[i];
}
h[i ++] = x;
}
int ok = 1;
for (int i = N - 1; i >= 0; i --) {
if (h[i] == -1) ok &= !f[i][N];
f[i].reset();
}
printf(ok ? "Yes\n" : "No\n");
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 3 4 BBBB BWBW WBBW 3 4 WBWB WBBB WBBW 4 4 BWBB BWWB WWBB WBWB 4 3 WBB BBW BWB WBB 4 3 WBB BWW WWW...
output:
No No Yes Yes No No Yes No No Yes
result:
ok 10 lines
Test #2:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 4 3 BWB BWW WWB WBW 3 3 BBW WBW BBW 3 4 WBWB BBWB BBWW 3 3 WBW BWW BWW 4 4 WWBB BWWB BWWB BBBW 3 ...
output:
No No No No Yes No No No No Yes
result:
ok 10 lines
Test #3:
score: 5
Accepted
time: 0ms
memory: 1192kb
input:
10 3 3 WBB BWW BBW 4 3 WBB BWW BBB WBW 4 4 BWWB WWWB WBBB WBBB 4 4 WBWB WBBB WBBB WBBW 3 3 WBW BBB B...
output:
No No Yes Yes No No No No Yes Yes
result:
ok 10 lines
Test #4:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 3 3 BWB WWW BBB 4 3 BWW BWW BBB WBW 4 4 BWBW BWWW BBWW WWWW 3 3 BBB BBB BWW 4 3 WBB WBW BWW WBB 3...
output:
No Yes Yes No No No No Yes No No
result:
ok 10 lines
Test #5:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 15 14 WWWWWWWWBBWBWW WWBWWBWBWWWWWB WBWWBBWWBBBBBB WBBWBWWBWWBWWB WBBBBBBWBBWWBW BWBWWWBBWBBWWW B...
output:
No No No No No No No No No No
result:
ok 10 lines
Test #6:
score: 5
Accepted
time: 0ms
memory: 1192kb
input:
10 15 15 BBBWBWWWWBWBWWW BBBBWBWBBBBWWWB BBBBBBBBBBBBWWB WBBBWWWBBBBWBBW BWBBWBWBWWWWWBB BBWWWWBWBBW...
output:
No Yes No No No No Yes Yes No No
result:
ok 10 lines
Test #7:
score: 5
Accepted
time: 0ms
memory: 1192kb
input:
10 14 14 WBWBBWWWWBBWBB BBWWWBBBWBBWWB BWBWWBBWBWBWBW BBWBWWBWWWBWWB WBWWBBBWBWWWBW WWBWBBBBBWWWBB W...
output:
Yes No No No Yes No Yes No Yes No
result:
ok 10 lines
Test #8:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 15 15 BBBBBBBWWWWBWWW BBWWWBWWBBWBBWB BWWBBBBWBBBWWBW WBWWBBWBWBBWBWW BWBWWWBBBBWWWWB WWWBBWWWBWW...
output:
No No No Yes Yes No No No No Yes
result:
ok 10 lines
Test #9:
score: 5
Accepted
time: 0ms
memory: 1188kb
input:
10 15 15 WBBWWWBBWWWWBWW BWWWWWBBBWBBBBB BWWWWWBWBWWWBWW WWWWBBBWWBWBBBB BWWWWWBWWBWBBWW WWWWBWBWBBB...
output:
No No No Yes No No No No No No
result:
ok 10 lines
Test #10:
score: 5
Accepted
time: 0ms
memory: 1192kb
input:
10 14 14 WBWWBBBBWWBBWB BWWWWBBWWBBWBB BWWBWWWBWWBWBW BWBBWBBWWBWWWW BBWBWWWBBBBBBB WWWWBWBBBBBWBB W...
output:
Yes No No Yes No No No No Yes No
result:
ok 10 lines
Test #11:
score: 5
Accepted
time: 2ms
memory: 1200kb
input:
10 99 100 BBBBBWBBBWWWBWBWWBBBWBWWBWWBBWBBWWBWWBWWBBWWWBWBWBWBBBWWBBBWWWWBBBBWWWBWWBWWBWBBWWWWBWWWWW...
output:
No Yes No Yes No No No Yes No Yes
result:
ok 10 lines
Test #12:
score: 5
Accepted
time: 1ms
memory: 1200kb
input:
10 99 99 BWWBWBWBBBBWWBWWWBBBBWWBBBBBWBWBBWBWWBBWBBBBWBWBBBWBWBBWWWWBBBWBWWBBBBBBWBBWWBBBBWWBWBWWBWB...
output:
No No Yes Yes No Yes No No No No
result:
ok 10 lines
Test #13:
score: 5
Accepted
time: 1ms
memory: 1196kb
input:
10 99 99 WBWBBWWWBWWBBWBWBWWBBWBWWBBWBBBWBBBWWWWWBWWBBBBBBWBBBWBBBBBWBBBWWBBWWBBBBBWWBWBBBBBBWBWBBBB...
output:
No Yes No No No No Yes No No No
result:
ok 10 lines
Test #14:
score: 5
Accepted
time: 1ms
memory: 1196kb
input:
10 100 99 BWBWBWWBBWBBBBWWBWBWWBWBBBBBWBBWWBWWBWWWBWBWBBWBWBBBWBBBBWBWBBWWBWWBWWBWBBWWWWWBBBBBWWWBWW...
output:
No No Yes Yes No No Yes Yes No No
result:
ok 10 lines
Test #15:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
10 99 99 WBBBWWBWBBWBWWBWBWWBWWBWBWWWBBBBWWWBBWWWBWBWWWWBBWWWBWBBBBWWBWWWWWBBBWWBBBWBBBBBBWWBWBBWWWW...
output:
No No Yes Yes Yes No No No No No
result:
ok 10 lines
Test #16:
score: 5
Accepted
time: 0ms
memory: 1200kb
input:
10 100 100 WBBWWBWBWWWWWBBBWBWWWWBWWWBBWWWBBWWWWWBWWBBWBBWWBBWBBWBBBBWWBBWBBWWBWBBWBBWBWWBBWBWWWBBWW...
output:
Yes Yes Yes No Yes No No No No No
result:
ok 10 lines
Test #17:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
10 99 100 WBWWWBWWWWWWBWBBWBWBWWWBWWBBWWBBBWBBBBBBBBBWWBBWWWWWBBWWWBWWWBBWWBWWWWWBBWWWBWWWWBBBWWBWBB...
output:
No No No No Yes Yes No Yes No No
result:
ok 10 lines
Test #18:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
10 100 99 BBBWWWBBWBBBBBBWBBWBWWBWBBBWWWBBBWBWBWBBBBWBWWWBBWWBBBWWWBBBWWWBBBBWBWBWBWBWBWWBWWWBWBBBBW...
output:
No No No No Yes No Yes No No No
result:
ok 10 lines
Test #19:
score: 5
Accepted
time: 0ms
memory: 1200kb
input:
10 100 99 BWBBWWWBWWWBBWBWBBWWWBWWWBBWWWBWWBBBWBWBWBBBBWBBBWWBBBWBWWBWWWBWBBBWBBWBBBBBBBBWWWWBBBBWWW...
output:
No No No No No Yes No No No No
result:
ok 10 lines
Test #20:
score: 5
Accepted
time: 0ms
memory: 1196kb
input:
10 99 99 WWBWBWBWBWBBBBWBBBBWWWBWWWWBBBBBBBBBWBWWBBWWBBWWWBBWWWBWWWBBWWWWWBWBWWBWWWBWBWBWWWBBWBBBWWB...
output:
No No No No No No No Yes No Yes
result:
ok 10 lines