QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198165 | #5953. Checkerboard Matrix | rootcucu | 0 | 13ms | 3772kb | C++17 | 1.2kb | 2023-10-03 05:58:36 | 2023-10-03 05:58:36 |
Judging History
answer
#include <tuple>
#include <iostream>
using namespace std;
void solve(){
int n; cin >> n;
int a[2005];
int b[2005];
int cc = 0, rc = 0;
int s = 0;
bool poss = true;
string m; cin >> m;
for (int i = 0; i < 2*n; i++){
a[i] = m[i] - '0';
s += a[i];
if (a[0] ^ a[i] ^ (i%2))
cc++;
}
if (s != n){
poss = false;
}
s = a[0];
for (int i = 1; i < 2*n; i++){
cin >> m;
for (int j = 0; j < 2*n; j++){
b[j] = m[j] - '0';
}
s += b[0];
if (a[0] ^ b[0] ^ (i%2))
rc++;
for (int j = 0; j < 2*n; j++){
if ((a[0]^b[0]^a[j]^b[j]) != 0){
poss = false;
}
}
}
if (!poss || s != n){
cout << "IMPOSSIBLE\n";
return;
}
cc /= 2;
rc /= 2;
// cout << min(cc+rc, min(n-cc+rc, n-rc+cc)) << "\n";
cout << min(cc+rc, n-cc+n-rc) << "\n";
}
int main(void){
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
for (int i = 1; i <= t; i++){
cout << "Case #" << i << ": ";
solve();
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
100 1 01 10 3 100110 100110 011001 011001 011001 100110 1 01 10 4 10110100 01101011 11100000 10110100 10110000 00001011 01001011 01001011 2 1010 1010 0101 0101 1 01 10 4 10001101 11010100 11000110 00111001 00101011 11010010 01100110 00111001 1 01 10 4 10110010 01100101 01101100 10010011 01101100 100...
output:
Case #1: 0 Case #2: 3 Case #3: 0 Case #4: IMPOSSIBLE Case #5: 1 Case #6: 0 Case #7: IMPOSSIBLE Case #8: 0 Case #9: IMPOSSIBLE Case #10: 0 Case #11: IMPOSSIBLE Case #12: 5 Case #13: IMPOSSIBLE Case #14: 0 Case #15: IMPOSSIBLE Case #16: IMPOSSIBLE Case #17: 3 Case #18: 0 Case #19: IMPOSSIBLE Case #20:...
result:
wrong answer 2nd lines differ - expected: 'Case #2: 2', found: 'Case #2: 3'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 13ms
memory: 3772kb
input:
100 82 01010110000101111001101100010110101011110011101100001000101000011100111001010110111000000110110010000110110010110010010010010010101100111001001100111111110100101011 01010110000101111001101100010110101011110011101100001000101000011100111001010110111000000110110010000110110010110010010010010010...
output:
Case #1: 79 Case #2: IMPOSSIBLE Case #3: IMPOSSIBLE Case #4: IMPOSSIBLE Case #5: IMPOSSIBLE Case #6: IMPOSSIBLE Case #7: IMPOSSIBLE Case #8: IMPOSSIBLE Case #9: IMPOSSIBLE Case #10: 68 Case #11: 83 Case #12: IMPOSSIBLE Case #13: IMPOSSIBLE Case #14: 95 Case #15: IMPOSSIBLE Case #16: IMPOSSIBLE Case ...
result:
wrong answer 1st lines differ - expected: 'Case #1: 73', found: 'Case #1: 79'