QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198485 | #5953. Checkerboard Matrix | rootcucu | 13 ✓ | 23ms | 3452kb | C++17 | 1.2kb | 2023-10-03 14:14:17 | 2023-10-03 14:14:18 |
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;
cc = min(cc,n-cc);
rc = min(rc,n-rc);
cout <<cc + 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: 4
Accepted
Test #1:
score: 4
Accepted
time: 0ms
memory: 3452kb
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: 2 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: 4 Case #13: IMPOSSIBLE Case #14: 0 Case #15: IMPOSSIBLE Case #16: IMPOSSIBLE Case #17: 2 Case #18: 0 Case #19: IMPOSSIBLE Case #20:...
result:
ok 100 lines
Subtask #2:
score: 9
Accepted
Test #2:
score: 9
Accepted
time: 23ms
memory: 3444kb
input:
100 82 01010110000101111001101100010110101011110011101100001000101000011100111001010110111000000110110010000110110010110010010010010010101100111001001100111111110100101011 01010110000101111001101100010110101011110011101100001000101000011100111001010110111000000110110010000110110010110010010010010010...
output:
Case #1: 73 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: 67 Case #11: 76 Case #12: IMPOSSIBLE Case #13: IMPOSSIBLE Case #14: 31 Case #15: IMPOSSIBLE Case #16: IMPOSSIBLE Case ...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed