CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Even Grid
Sender:bielaltes
Submission time:2024-11-27 17:49:54 +0200
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.01 sdetails
#110.01 sdetails

Code

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<char>> matrix(n, vector<char>(n));
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> matrix[i][j];
        }
    }
    
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < n; j++) {
            if (matrix[i][j] == '?') {
                int row_ones = 0;
                for (int k = 0; k < j; k++) {
                    row_ones += (matrix[i][k] == '1');
                }
                for (int k = j + 1; k < n; k++) {
                    if (matrix[i][k] != '?') {
                        row_ones += (matrix[i][k] == '1');
                    }
                }
                
                int col_ones = 0;
                for (int k = 0; k < i; k++) {
                    col_ones += (matrix[k][j] == '1');
                }
                
                if ((row_ones % 2) == (col_ones % 2)) {
                    matrix[i][j] = '0';
                } else {
                    matrix[i][j] = '1';
                }
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << matrix[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

Test details

Test 1

Verdict:

input
2
11
1?

correct output
11
11

user output
11
10

Test 2

Verdict:

input
3
101
1??
0??

correct output
101
101
000

user output
101
111
011

Test 3

Verdict:

input
4
1010
0???
1???
0???

correct output
1010
0000
1010
0000

user output
1010
0011
1101
0110

Test 4

Verdict:

input
5
11101
1????
1????
1????
...

correct output
11101
11101
11101
11101
00000

user output
11101
10011
10001
10000
01000

Test 5

Verdict:

input
5
10111
1????
1????
0????
...

correct output
10111
10111
10111
00000
10111

user output
10111
11100
10110
01011
11101

Test 6

Verdict:

input
5
11000
0????
0????
0????
...

correct output
11000
00000
00000
00000
11000

user output
11000
01100
00110
00011
11001

Test 7

Verdict:

input
5
10100
1????
0????
1????
...

correct output
10100
10100
00000
10100
10100

user output
10100
11110
01111
11111
10111

Test 8

Verdict:

input
5
10100
1????
1????
0????
...

correct output
10100
10100
10100
00000
10100

user output
10100
11110
10111
01011
11101

Test 9

Verdict:

input
10
1010000000
1?????????
0?????????
0?????????
...

correct output
1010000000
1010000000
0000000000
0000000000
0000000000
...

user output
1010000000
1111000000
0111100000
0011110000
0001111000
...

Test 10

Verdict:

input
100
100010110100011000001111001110...

correct output
100010110100011000001111001110...

user output
100010110100011000001111001110...

Test 11

Verdict:

input
100
100100110000010110111101111101...

correct output
100100110000010110111101111101...

user output
100100110000010110111101111101...