QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198397 | #5953. Checkerboard Matrix | rootcucu | 0 | 19ms | 3564kb | C++17 | 1.3kb | 2023-10-03 13:38:56 | 2023-10-03 13:38:56 |
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 << "\n";
//cout << "cc " << cc << ", ";
//cout << "rc " << rc << "\n";
cout << min(cc+rc, n-cc+n-rc) << "\n";
// cout << min(cc+rc, min(n-cc+rc, n-rc+cc)) << "\n";
// cout << "\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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3524kb
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: 19ms
memory: 3564kb
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'