QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103909 | #6377. LaLa and Magic Stone | chenshi# | WA | 9ms | 2544kb | C++ | 1.8kb | 2023-05-07 20:22:22 | 2023-05-07 20:22:23 |
Judging History
answer
#include<cstdio>
using namespace std;
const int o=1010,MOD=998244353;
int n,m,ans=1;char s[o][o];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(s[i][j]=='0'){
if(s[i][j+2]!='0'||s[i+2][j]!='0'||s[i+2][j+2]!='0'){printf("0");return 0;}
if(s[i+1][j+1]=='0'){
if(s[i][j+1]!='0'||s[i][j+2]!='0'||s[i][j+3]!='1'
||s[i+1][j]!='0'||s[i+1][j+1]!='0'||s[i+1][j+2]!='0'||s[i+1][j+3]!='0'
||s[i+2][j]!='0'||s[i+2][j+1]!='0'||s[i+2][j+2]!='0'||s[i+2][j+3]!='0'
||s[i+3][j]!='1'||s[i+3][j+1]!='0'||s[i+3][j+2]!='0'||s[i+3][j+3]!='0'){printf("0");return 0;}
ans=ans*2%MOD;
for(int k=i;k<=i+3;++k) for(int $=j;$<=j+3;++$) s[k][$]='1';
}
else{
if((s[i][j+1]=='1')+(s[i+1][j]=='1')+(s[i+1][j+2]=='1')+(s[i+2][j+1]=='1')==1)
for(int k=i;k<=i+2;++k) for(int $=j;$<=j+2;++$) s[k][$]='1';
else if(s[i][j+1]=='0'&&s[i][j+2]=='0'&&s[i][j+3]=='1'&&s[i][j+4]=='1'
&&s[i+1][j]=='0'&&s[i+1][j+1]=='1'&&s[i+1][j+2]=='0'&&s[i+1][j+3]=='0'&&s[i+1][j+4]=='0'
&&s[i+2][j]=='0'&&s[i+2][j+1]=='0'&&s[i+2][j+2]=='0'&&s[i+2][j+3]=='1'&&s[i+2][j+4]=='0'
&&s[i+3][j]=='1'&&s[i+3][j+1]=='1'&&s[i+3][j+2]=='0'&&s[i+3][j+3]=='0'&&s[i+3][j+4]=='0')
for(int k=i;k<=i+3;++k) for(int $=j;$<=j+4;++$) s[k][$]='1';
else if(s[i][j+1]=='0'&&s[i][j+2]=='0'&&s[i][j+3]=='1'
&&s[i+1][j]=='0'&&s[i+1][j+1]=='1'&&s[i+1][j+2]=='0'&&s[i+1][j+3]=='1'
&&s[i+2][j]=='0'&&s[i+2][j+1]=='0'&&s[i+2][j+2]=='0'&&s[i+2][j+3]=='0'
&&s[i+3][j]=='1'&&s[i+3][j+1]=='0'&&s[i+3][j+2]=='1'&&s[i+3][j+3]=='0'
&&s[i+4][j]=='1'&&s[i+4][j+1]=='0'&&s[i+4][j+2]=='0'&&s[i+4][j+3]=='0')
for(int k=i;k<=i+4;++k) for(int $=j;$<=j+3;++$) s[k][$]='1';
else{printf("0");return 0;}
}
}
printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 1544kb
input:
4 4 0001 0000 0000 1000
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 1544kb
input:
5 4 0001 0101 0000 1010 1000
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 1544kb
input:
3 3 111 111 111
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 1492kb
input:
3 4 1111 1111 1111
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 1520kb
input:
3 1000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 1ms
memory: 1508kb
input:
4 3 111 111 111 111
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 1496kb
input:
4 4 1111 1111 1111 1111
output:
1
result:
ok 1 number(s): "1"
Test #8:
score: 0
Accepted
time: 1ms
memory: 1528kb
input:
4 1000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
1
result:
ok 1 number(s): "1"
Test #9:
score: 0
Accepted
time: 1ms
memory: 2500kb
input:
1000 3 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 1...
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 0ms
memory: 2544kb
input:
1000 4 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 111...
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 9ms
memory: 2416kb
input:
1000 1000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
1
result:
ok 1 number(s): "1"
Test #12:
score: 0
Accepted
time: 0ms
memory: 1744kb
input:
3 3 000 010 010
output:
1
result:
ok 1 number(s): "1"
Test #13:
score: 0
Accepted
time: 1ms
memory: 1548kb
input:
3 3 000 011 000
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 1ms
memory: 1540kb
input:
3 3 010 010 000
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 1ms
memory: 1756kb
input:
3 3 000 110 000
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: -100
Wrong Answer
time: 1ms
memory: 1876kb
input:
4 4 1000 0000 0000 0001
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'