ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215031 | #2705. Yet another lights out | fddwd | 25 | 463ms | 4044kb | C++11 | 828b | 2024-11-25 20:25:07 | 2024-11-25 23:09:18 |
answer
#include<bits/stdc++.h>
using namespace std;
int t,n,m;
string o[100],s[100];
bool vh[65536];
inline int cal(){
int num=0;
for(int i=0;i<n;++i)for(int j=0;j<m;++j)
num=num*2+(s[i][j]=='B');
return num;
}inline void perf(int x,int y){
for(int i=0;i<n;++i) s[i][y]=(s[i][y]=='B'?'W':'B');
for(int j=0;j<m;++j)if(j!=y) s[x][j]=(s[x][j]=='B'?'W':'B');
}inline void dfs(){
int num1=cal();
if(vh[num1]) return;
vh[num1]=true;
for(int i=0;i<n;++i)for(int j=0;j<m;++j)
perf(i,j),dfs(),perf(i,j);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>t;
while(t--){
cin>>n>>m;
for(int i=0;i<n;++i) cin>>o[i],s[i]=o[i];
if(n<=4&&m<=4){
memset(vh,false,sizeof(vh));
dfs();
cout<<(vh[0]?"Yes":"No")<<endl;
continue;
}cout<<"No"<<endl;
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 107ms
memory: 4044kb
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: 101ms
memory: 4040kb
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: 155ms
memory: 4044kb
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: 98ms
memory: 4044kb
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: 1252kb
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: 0
Wrong Answer
time: 0ms
memory: 1252kb
input:
10 15 15 BBBWBWWWWBWBWWW BBBBWBWBBBBWWWB BBBBBBBBBBBBWWB WBBBWWWBBBBWBBW BWBBWBWBWWWWWBB BBWWWWBWBBW...
output:
No No No No No No No No No No
result:
wrong answer 2nd lines differ - expected: 'Yes', found: 'No'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 1252kb
input:
10 14 14 WBWBBWWWWBBWBB BBWWWBBBWBBWWB BWBWWBBWBWBWBW BBWBWWBWWWBWWB WBWWBBBWBWWWBW WWBWBBBBBWWWBB W...
output:
No No No No No No No No No No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 1252kb
input:
10 15 15 BBBBBBBWWWWBWWW BBWWWBWWBBWBBWB BWWBBBBWBBBWWBW WBWWBBWBWBBWBWW BWBWWWBBBBWWWWB WWWBBWWWBWW...
output:
No No No No No No No No No No
result:
wrong answer 4th lines differ - expected: 'Yes', found: 'No'
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 1256kb
input:
10 15 15 WBBWWWBBWWWWBWW BWWWWWBBBWBBBBB BWWWWWBWBWWWBWW WWWWBBBWWBWBBBB BWWWWWBWWBWBBWW WWWWBWBWBBB...
output:
No No No No No No No No No No
result:
wrong answer 4th lines differ - expected: 'Yes', found: 'No'
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 1252kb
input:
10 14 14 WBWWBBBBWWBBWB BWWWWBBWWBBWBB BWWBWWWBWWBWBW BWBBWBBWWBWWWW BBWBWWWBBBBBBB WWWWBWBBBBBWBB W...
output:
No No No No No No No No No No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 1268kb
input:
10 99 100 BBBBBWBBBWWWBWBWWBBBWBWWBWWBBWBBWWBWWBWWBBWWWBWBWBWBBBWWBBBWWWWBBBBWWWBWWBWWBWBBWWWWBWWWWW...
output:
No No No No No No No No No No
result:
wrong answer 2nd lines differ - expected: 'Yes', found: 'No'
Test #12:
score: 0
Wrong Answer
time: 0ms
memory: 1268kb
input:
10 99 99 BWWBWBWBBBBWWBWWWBBBBWWBBBBBWBWBBWBWWBBWBBBBWBWBBBWBWBBWWWWBBBWBWWBBBBBBWBBWWBBBBWWBWBWWBWB...
output:
No No No No No No No No No No
result:
wrong answer 3rd lines differ - expected: 'Yes', found: 'No'
Test #13:
score: 0
Wrong Answer
time: 0ms
memory: 1272kb
input:
10 99 99 WBWBBWWWBWWBBWBWBWWBBWBWWBBWBBBWBBBWWWWWBWWBBBBBBWBBBWBBBBBWBBBWWBBWWBBBBBWWBWBBBBBBWBWBBBB...
output:
No No No No No No No No No No
result:
wrong answer 2nd lines differ - expected: 'Yes', found: 'No'
Test #14:
score: 0
Wrong Answer
time: 1ms
memory: 1272kb
input:
10 100 99 BWBWBWWBBWBBBBWWBWBWWBWBBBBBWBBWWBWWBWWWBWBWBBWBWBBBWBBBBWBWBBWWBWWBWWBWBBWWWWWBBBBBWWWBWW...
output:
No No No No No No No No No No
result:
wrong answer 3rd lines differ - expected: 'Yes', found: 'No'
Test #15:
score: 0
Wrong Answer
time: 0ms
memory: 1268kb
input:
10 99 99 WBBBWWBWBBWBWWBWBWWBWWBWBWWWBBBBWWWBBWWWBWBWWWWBBWWWBWBBBBWWBWWWWWBBBWWBBBWBBBBBBWWBWBBWWWW...
output:
No No No No No No No No No No
result:
wrong answer 3rd lines differ - expected: 'Yes', found: 'No'
Test #16:
score: 0
Wrong Answer
time: 0ms
memory: 1272kb
input:
10 100 100 WBBWWBWBWWWWWBBBWBWWWWBWWWBBWWWBBWWWWWBWWBBWBBWWBBWBBWBBBBWWBBWBBWWBWBBWBBWBWWBBWBWWWBBWW...
output:
No No No No No No No No No No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'
Test #17:
score: 0
Wrong Answer
time: 0ms
memory: 1268kb
input:
10 99 100 WBWWWBWWWWWWBWBBWBWBWWWBWWBBWWBBBWBBBBBBBBBWWBBWWWWWBBWWWBWWWBBWWBWWWWWBBWWWBWWWWBBBWWBWBB...
output:
No No No No No No No No No No
result:
wrong answer 5th lines differ - expected: 'Yes', found: 'No'
Test #18:
score: 0
Wrong Answer
time: 1ms
memory: 1268kb
input:
10 100 99 BBBWWWBBWBBBBBBWBBWBWWBWBBBWWWBBBWBWBWBBBBWBWWWBBWWBBBWWWBBBWWWBBBBWBWBWBWBWBWWBWWWBWBBBBW...
output:
No No No No No No No No No No
result:
wrong answer 5th lines differ - expected: 'Yes', found: 'No'
Test #19:
score: 0
Wrong Answer
time: 0ms
memory: 1272kb
input:
10 100 99 BWBBWWWBWWWBBWBWBBWWWBWWWBBWWWBWWBBBWBWBWBBBBWBBBWWBBBWBWWBWWWBWBBBWBBWBBBBBBBBWWWWBBBBWWW...
output:
No No No No No No No No No No
result:
wrong answer 6th lines differ - expected: 'Yes', found: 'No'
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 1272kb
input:
10 99 99 WWBWBWBWBWBBBBWBBBBWWWBWWWWBBBBBBBBBWBWWBBWWBBWWWBBWWWBWWWBBWWWWWBWBWWBWWWBWBWBWWWBBWBBBWWB...
output:
No No No No No No No No No No
result:
wrong answer 8th lines differ - expected: 'Yes', found: 'No'