QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#335582#2921. Land EqualityamshaleAC ✓0ms4036kbC++201.3kb2024-02-23 16:32:142024-02-23 16:32:15

Judging History

你现在查看的是最新测评结果

  • [2024-02-23 16:32:15]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:4036kb
  • [2024-02-23 16:32:14]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

int main() {
    int rows,columns;
    scanf("%d",&rows);
    scanf("%d",&columns);
    int zeroes=0;
    int doubles=0;
    int freeones=0;
    int ones=0;
    int curr_num;
    for(int i=0;i<rows;i++){
        for(int j=0;j<columns;j++){
            scanf("%d",&curr_num);
            if(curr_num==0){
                zeroes++;
            }
            else if(curr_num==2){
                doubles++;
            }
            else{
            ones++;
            if((columns==1&&(i==0||i==rows-1))||rows==1&&(j==0||j==columns-1)){
                freeones++;
            }            
        }
    }
    }
    if((columns==1||rows==1)&&zeroes==1){
        if(freeones>0){
            printf("1\n");
            return 0;
        }else{
            printf("2\n");
            return 0;
        }
        
    }else if(zeroes==0){
        if(doubles%2==0){
            printf("0\n");
            return 0;
        }
        else{
            printf("%ld\n",(long)(pow(2,(doubles/2))));
            return 0;
    }
    }
    else if(zeroes==1){
        if(ones>0){         
            printf("1\n");
        }
        else{
            printf("2\n");
    }
    }
    else{
        printf("0\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

1 2
0 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

1 2
0 2

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

1 2
1 2

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

2 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

2 1
0
0

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

5 5
2 2 2 2 2
2 2 1 2 2
2 1 1 1 2
2 2 1 2 2
2 2 2 2 2

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

5 5
2 2 2 2 2
2 2 1 2 2
2 1 1 1 2
2 2 1 1 2
2 2 2 2 2

output:

512

result:

ok single line: '512'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

2 3
0 1 2
1 1 2

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

2 6
0 2 2 1 2 2
1 1 1 1 2 2

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

4 4
2 2 2 2
2 1 2 2
2 0 2 2
2 2 2 2

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1 3
0 1 2

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

1 6
2 1 2 0 1 2

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

6 1
2
1
2
0
1
2

output:

2

result:

ok single line: '2'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

1 5
0 1 1 1 2

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

1 6
2 1 2 0 2 1

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

1 6
1 1 2 0 1 2

output:

1

result:

ok single line: '1'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

6 1
2
1
2
0
2
1

output:

1

result:

ok single line: '1'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

1 10
2 1 1 1 0 0 1 1 1 2

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1 10
1 2 0 2 2 2 2 0 2 1

output:

0

result:

ok single line: '0'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

1 10
0 1 1 1 2 2 1 1 1 0

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

8 8
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 1 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2

output:

2147483648

result:

ok single line: '2147483648'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

8 8
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

8 8
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1

output:

0

result:

ok single line: '0'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

8 8
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

7 9
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2

output:

2147483648

result:

ok single line: '2147483648'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

31 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2
2 2

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 0ms
memory: 4004kb

input:

1 61
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

output:

1073741824

result:

ok single line: '1073741824'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

8 8
1 0 0 1 1 1 1 0
1 1 1 0 1 1 0 0
1 1 0 1 0 1 1 0
0 1 1 1 0 1 1 1
1 1 1 1 0 0 1 1
1 0 0 1 1 0 1 1
1 0 0 0 1 1 0 1
1 0 0 0 1 1 1 0

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

6 10
0 0 0 1 0 1 1 0 0 0
0 1 0 1 0 0 0 0 1 1
0 1 0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 0 0 1
0 1 0 1 0 0 1 0 1 1
1 0 0 1 1 0 1 0 0 0

output:

0

result:

ok single line: '0'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

8 8
2 0 2 2 2 2 2 2
0 2 0 0 0 2 2 2
0 2 2 0 2 2 0 0
0 2 2 2 0 2 0 2
2 2 0 2 0 0 2 0
0 2 0 2 2 0 2 2
0 2 0 0 2 0 2 2
2 2 2 0 0 0 2 2

output:

0

result:

ok single line: '0'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

10 6
2 0 2 2 0 2
0 0 2 2 0 2
2 2 0 2 0 2
2 2 2 0 2 0
0 0 2 0 0 2
2 2 2 0 2 2
2 0 0 0 2 0
2 2 0 2 0 0
0 2 2 2 0 0
0 0 0 2 2 0

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

8 8
1 1 2 1 2 1 1 1
1 2 1 1 2 2 1 1
2 2 1 2 1 2 2 1
1 1 2 2 1 1 1 2
1 2 1 1 2 1 1 1
1 1 1 2 2 1 2 1
1 2 2 1 2 1 2 1
1 2 2 2 2 2 1 1

output:

8192

result:

ok single line: '8192'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

7 9
2 2 2 2 1 1 1 1 1
1 2 2 2 1 1 2 2 1
1 1 2 1 1 2 2 2 2
2 1 1 1 2 2 2 1 2
2 1 1 1 1 1 2 1 1
2 2 2 2 1 2 2 1 2
2 2 2 2 1 1 1 2 1

output:

65536

result:

ok single line: '65536'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3964kb

input:

9 7
2 1 1 1 2 1 2
2 2 1 2 2 1 2
2 1 1 2 1 1 2
1 2 2 2 2 1 2
1 1 1 1 2 2 2
1 2 1 2 2 2 2
1 1 1 1 1 1 1
2 2 2 2 2 2 2
1 2 1 1 2 1 1

output:

65536

result:

ok single line: '65536'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

8 8
2 1 0 0 2 1 2 2
1 0 0 1 1 0 2 0
1 0 1 2 0 1 0 2
1 2 1 2 1 2 1 2
0 0 1 2 1 0 0 2
0 0 2 1 2 0 2 1
2 1 1 1 1 0 2 0
0 0 1 2 0 1 1 0

output:

0

result:

ok single line: '0'

Test #36:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

7 9
1 1 1 0 2 1 1 2 0
2 1 2 2 2 2 2 0 1
2 0 2 2 0 1 2 0 2
0 2 2 0 0 2 1 1 2
0 0 1 1 1 1 0 1 1
1 2 0 1 1 0 1 1 0
0 2 0 1 2 2 0 0 2

output:

0

result:

ok single line: '0'

Test #37:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

9 7
2 2 0 2 2 1 2
2 0 2 0 1 1 1
2 1 1 0 1 0 2
0 0 0 1 1 0 1
1 2 1 2 2 2 0
1 2 0 0 0 0 2
1 2 1 0 1 2 2
0 2 2 2 2 0 2
2 0 2 0 2 0 1

output:

0

result:

ok single line: '0'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1 64
0 2 1 2 0 1 2 0 2 1 1 2 2 2 2 2 1 2 2 1 2 0 0 1 2 1 1 0 0 2 0 1 1 1 1 1 2 1 2 1 2 0 2 2 0 0 1 1 2 2 1 1 1 1 0 0 2 1 2 2 2 0 2 1

output:

0

result:

ok single line: '0'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

64 1
1
1
0
0
1
2
0
1
0
1
0
2
2
2
0
2
1
1
2
1
0
0
2
0
0
1
2
0
1
0
0
2
1
1
0
2
2
0
2
0
1
0
0
1
2
1
0
1
1
2
2
0
1
1
0
0
0
0
2
0
2
1
1
2

output:

0

result:

ok single line: '0'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

2 32
0 2 2 2 2 1 1 1 2 1 1 2 1 1 2 0 1 1 2 2 2 2 0 0 0 0 0 1 2 1 0 2
0 1 2 2 2 1 1 1 0 0 1 2 2 2 0 0 0 1 1 2 0 0 1 2 2 0 0 2 2 0 2 0

output:

0

result:

ok single line: '0'

Test #41:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

32 2
1 0
1 2
2 0
0 1
0 0
0 2
1 0
1 1
0 2
1 0
1 1
2 0
1 1
1 2
2 0
1 1
0 0
2 0
2 1
1 2
0 2
2 0
0 1
1 2
0 1
1 1
1 1
0 0
2 2
0 1
0 0
2 0

output:

0

result:

ok single line: '0'

Test #42:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

1 63
1 1 1 2 0 1 1 1 2 1 1 1 2 1 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 1

output:

1

result:

ok single line: '1'

Test #43:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

1 64
1 2 1 2 2 1 1 1 0 2 1 1 2 1 2 2 2 2 1 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 1 2 2 2 1 2 2 2 2 2 1 2 1 1 2 2 1 1 2 2 2 2 2 1 2 2 1 2 1 2

output:

1

result:

ok single line: '1'

Test #44:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

63 1
1
1
1
1
2
1
1
1
1
2
2
1
1
2
2
2
2
1
2
2
2
1
1
1
1
2
2
1
2
1
2
1
1
1
2
1
1
2
2
2
2
1
1
1
2
1
2
1
2
2
1
1
2
1
1
0
1
2
2
1
1
1
1

output:

1

result:

ok single line: '1'

Test #45:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

64 1
2
1
2
1
2
1
1
1
1
2
2
1
2
2
2
1
2
1
1
1
2
1
2
1
2
2
2
2
1
1
1
2
2
1
2
0
1
1
2
2
2
2
2
2
2
2
1
2
2
1
1
2
2
2
1
2
2
2
2
1
1
1
1
2

output:

2

result:

ok single line: '2'

Test #46:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

8 8
2 1 1 2 1 1 2 2
1 1 1 1 1 1 2 1
1 2 2 1 2 2 2 1
1 2 1 1 1 2 2 0
1 1 1 1 2 1 1 1
2 1 2 2 2 2 1 1
1 2 2 1 1 2 1 1
1 2 1 2 2 1 2 2

output:

1

result:

ok single line: '1'

Test #47:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

2 32
2 1 1 2 0 2 2 2 1 1 2 1 2 2 1 1 2 1 2 2 2 1 1 2 2 1 1 1 2 2 2 1
1 1 1 2 2 2 2 2 1 2 2 1 1 2 1 2 2 2 1 1 2 1 2 2 2 1 2 1 2 1 2 2

output:

1

result:

ok single line: '1'

Test #48:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

32 2
2 2
1 1
2 1
1 1
2 1
1 2
1 1
1 1
1 2
2 2
1 1
2 1
1 1
2 1
1 1
1 1
2 1
1 2
1 2
1 1
1 2
1 0
1 2
1 1
1 1
2 1
2 1
2 1
1 2
2 2
1 2
2 2

output:

1

result:

ok single line: '1'

Test #49:

score: 0
Accepted
time: 0ms
memory: 4036kb

input:

3 4
1 2 1 1
2 2 1 2
1 2 2 2

output:

8

result:

ok single line: '8'

Test #50:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

2 3
0 1 2
0 1 2

output:

0

result:

ok single line: '0'

Test #51:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1 3
2 0 2

output:

2

result:

ok single line: '2'