ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#192670 | #2705. Yet another lights out | tkswls | 100 | 12ms | 1272kb | C++ | 967b | 2023-10-10 11:18:28 | 2023-10-10 12:11:54 |
answer
#include<bits/stdc++.h>
using namespace std;
int t, a[105][105], n, m, sum[105], ssum[105];
char c;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> c;
if (c == 'W') {
a[i][j] = 0;
} else {
a[i][j] = 1;
}
}
}
for (int i = 1; i <= n; i++) {
sum[i] = 0;
}
for (int i = 1; i <= m; i++) {
ssum[i] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
sum[i] += a[i][j];
ssum[j] += a[i][j];
}
}
bool flg = false, fflg = false;
for (int i = 2; i <= n; i++) {
if (sum[i] % 2 != sum[i - 1] % 2) flg = true;
}
for (int i = 2; i <= m; i++) {
if (ssum[i] % 2 != ssum[i - 1] % 2) fflg = true;
}
if ((flg && (m % 2)) || (fflg && (n % 2))) {
cout << "No\n";
} else {
cout << "Yes\n";
}
}
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1224kb
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: 1224kb
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: 1224kb
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: 1228kb
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: 1228kb
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: 1232kb
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: 1228kb
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: 1228kb
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: 1228kb
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: 1232kb
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: 1268kb
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: 3ms
memory: 1268kb
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: 0ms
memory: 1272kb
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: 0ms
memory: 1272kb
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: 2ms
memory: 1268kb
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: 1268kb
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: 1ms
memory: 1268kb
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: 2ms
memory: 1272kb
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: 2ms
memory: 1272kb
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: 1268kb
input:
10 99 99 WWBWBWBWBWBBBBWBBBBWWWBWWWWBBBBBBBBBWBWWBBWWBBWWWBBWWWBWWWBBWWWWWBWBWWBWWWBWBWBWWWBBWBBBWWB...
output:
No No No No No No No Yes No Yes
result:
ok 10 lines