Submission #1010626

# Submission time Handle Problem Language Result Execution time Memory
1010626 2024-06-29T08:34:19 Z LucaIlie Red-blue table (IZhO19_stones) C++17
11 / 100
24 ms 2156 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000;
char mat[MAX_N][MAX_N];
int sumL[MAX_N], sumC[MAX_N];

int main() {
    int t;

    cin >> t;
    for ( ; t > 0; t-- ) {
        int n, m;

        cin >> n >> m;

        if ( n % 2 == 1 ) {
            for ( int l = 0; l < n; l++ ) {
                for ( int c = 0; c < m; c++ ) {
                    if ( l == n - 1 && m != 1 )
                        mat[l][c] = '-';
                    else {
                        if ( l < n / 2 ) {
                            if ( c <= m / 2 )
                                mat[l][c] = '+';
                            else
                                mat[l][c] = '-';
                        } else {
                            if ( c < m / 2 )
                                mat[l][c] = '-';
                            else
                                mat[l][c] = '+';
                        }
                    }
                }
            }
        } else {
            for ( int l = 0; l < n; l++ ) {
                for ( int c = 0; c < m; c++ ) {
                    if ( l >= n - 2 && m != 1 )
                        mat[l][c] = '-';
                    else {
                        if ( l < n / 2 ) {
                            if ( c <= m / 2 )
                                mat[l][c] = '+';
                            else
                                mat[l][c] = '-';
                        } else {
                            if ( c < m / 2 )
                                mat[l][c] = '-';
                            else
                                mat[l][c] = '+';
                        }
                    }
                }
            }
        }

        for ( int l = 0; l < n; l++ )
            sumL[l] = 0;
        for ( int c = 0; c < m; c++ )
            sumC[c] = 0;
        for ( int l = 0; l < n; l++ ) {
            for ( int c = 0; c < m; c++ ) {
                sumL[l] += (mat[l][c] == '+' ? 1 : -1);
                sumC[c] += (mat[l][c] == '+' ? -1 : +1);
            }
        }

        int r = 0;
        for ( int l = 0; l < n; l++ )
            r += (sumL[l] > 0);
        for ( int c = 0; c < m; c++ )
            r += (sumC[c] > 0);

        cout << r << "\n";
        for ( int l = 0; l < n; l++ ) {
            for ( int c = 0; c < m; c++ )
                cout << mat[l][c];
            cout << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Wrong answer in test 4 4: 3 < 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong answer in test 20 2: 10 < 20
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Wrong answer in test 4 4: 3 < 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1368 KB Output is correct
2 Correct 18 ms 1880 KB Output is correct
3 Correct 17 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1368 KB Wrong answer in test 24 24: 23 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Wrong answer in test 4 4: 3 < 5
3 Halted 0 ms 0 KB -