QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89909#94. Good Old TablesnpmrnhlolWA 1025ms38688kbC++141.9kb2023-03-21 19:22:182023-03-21 19:22:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-21 19:22:20]
  • 评测
  • 测评结果:WA
  • 用时:1025ms
  • 内存:38688kb
  • [2023-03-21 19:22:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//ifstream fin("cross.in");
//ofstream fout("cross.out");
int v[3000][3000];
int v2[3000];
int v3[3000];
int checker[3000];
int main() {
    int n,m,i,j,a = 0,ans = 0,cnt = 0;
    cin>>n>>m;
    if(n == 1 || m == 1){
        for(i = 0;i < n;i++){
            for(j = 0;j < m;j++){
                cin>>v[i][j];
                cnt+=2-v[i][j];
            }
        }
        if(cnt == n*m){
            cout<<0;
        }else if(cnt == 0){
            cout<<1;
        }else cout<<-1;
    }else if(n%2 == m%2){
        for(i = 0;i < n;i++){
            for(j = 0;j < m;j++){
                cin>>v[i][j];
                if(v[i][j] == 2){v2[i]++;v3[j]++;};
            }
        }
        for(i = 0;i < n;i++){
            for(j = 0;j < m;j++){
                a = 0;
                if(v[i][j] == 2)a++;
                a+=v2[i];a+=v3[j];
                if(a%2 == 1)ans++;
            }
        }
        cout<<ans;
    }else if(n%2 == 1){
        for(i = 0;i < n;i++){
            for(j = 0;j < m;j++){
                cin>>v[i][j];
                if(v[i][j] == 2){if(i != n - 1){v2[i]++;v3[j]++;}
                    checker[j]++;
                    if(i != n - 1)cnt++;
                };
            }
        }
        bool q[2];
        for(j = 0;j < m;j++){
            q[(checker[j] + cnt)%2]++;
        }
        if(q[0] && q[1]){
            cout<<-1;
            return 0;
        }else if(q[1]){
            v3[0]++;
        }
        for(i = 0;i < n - 1;i++){
            for(j = 0;j < m;j++){
                a = 0;
                if(v[i][j] == 2)a++;
                a+=v2[i];a+=v3[j];
                //cout<<a<<' ';
                if(a%2 == 1)ans++;
            }
            //cout<<'\n';
        }
        cout<<min(ans,(n-1)*m - ans) + 1;
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1024ms
memory: 38688kb

input:

3000 3000
2 1 2 1 2 1 1 1 1 2 1 1 2 2 1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 2 2 1 1 1 1 2 1 2 1 2 1 2 2 2 2 1 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 1 1 2 1 1 2 1 2 2 1 1 1 2 2 2 2 1 1 2 2 2 2 2 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 2 ...

output:

4499318

result:

ok 1 number(s): "4499318"

Test #2:

score: 0
Accepted
time: 1015ms
memory: 38540kb

input:

3000 3000
1 2 2 2 1 2 2 1 1 1 2 1 2 1 2 2 2 1 2 1 1 2 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 2 1 1 2 2 1 2 2 1 2 2 2 1 2 1 1 1 2 2 1 2 1 2 1 2 2 1 2 2 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 1 1 1 1 2 2 1 1 2 1 1 2 1 1 1 1 2 2 2 2 2 2 1 1 2 2 1 1 1 1 2 1 2 2 2 1 2 2 1 2 1 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 1 2 2 2 1 2 ...

output:

4500268

result:

ok 1 number(s): "4500268"

Test #3:

score: 0
Accepted
time: 1025ms
memory: 38524kb

input:

3000 3000
1 1 2 2 2 2 1 2 1 1 2 1 2 2 2 2 1 2 1 1 1 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 1 2 1 2 1 1 2 2 2 1 2 2 2 1 2 1 1 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 1 1 1 1 1 2 1 2 1 1 2 2 2 2 2 2 2 1 2 1 2 1 1 2 1 2 1 1 1 2 2 2 1 2 1 1 2 1 1 2 1 1 1 2 2 1 2 2 2 2 2 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 2 2 1 1 2 2 2 2 2 ...

output:

4499488

result:

ok 1 number(s): "4499488"

Test #4:

score: 0
Accepted
time: 911ms
memory: 38664kb

input:

3000 3000
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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 956ms
memory: 38564kb

input:

3000 3000
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 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

9000000

result:

ok 1 number(s): "9000000"

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 3492kb

input:

712 2467
2 1 2 2 2 2 2 2 2 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 2 1 1 2 2 2 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 2 1 1 1 1 1 2 1 2 2 2 2 1 1 2 2 1 1 1 1 2 1 1 1 1 2 1 1 1 2 2 2 2 2 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 1 1 2 1 2 1 1 1 1 1 2 2 2 2 2...

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements