QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89909 | #94. Good Old Table | snpmrnhlol | WA | 1025ms | 38688kb | C++14 | 1.9kb | 2023-03-21 19:22:18 | 2023-03-21 19:22:20 |
Judging History
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;
}
詳細信息
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