QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198163#5953. Checkerboard Matrixrootcucu0 28ms3460kbC++171.1kb2023-10-03 05:54:072023-10-03 05:54:08

Judging History

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

  • [2023-10-03 05:54:08]
  • 评测
  • 测评结果:0
  • 用时:28ms
  • 内存:3460kb
  • [2023-10-03 05:54:07]
  • 提交

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";
}

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: 1ms
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:

wrong answer 64th lines differ - expected: 'Case #64: 2', found: 'Case #64: 9'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 28ms
memory: 3460kb

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:

wrong answer 34th lines differ - expected: 'Case #34: 14', found: 'Case #34: 82'