Submission #668403

# Submission time Handle Problem Language Result Execution time Memory
668403 2022-12-03T19:54:09 Z YENGOYAN Red-blue table (IZhO19_stones) C++17
38 / 100
45 ms 1252 KB
#include <iostream>
#include <vector>

using namespace std;

void solve() {
    int n, m; cin >> n >> m;
    if (min(m, n) <= 3 || (n <= 4 && m <= 4)) {
        if (n + (m + 1) / 2 - 1 > m + (n + 1) / 2 - 1) {
            cout << n + (m + 1) / 2 - 1 << endl;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (j <= m / 2 + 1) cout << '+';
                    else cout << '-';
                }
                cout << "\n";
            }
        }
        else {
            cout << m + (n + 1) / 2 - 1 << endl;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (i <= n / 2 + 1) cout << '-';
                    else cout << '+';
                }
                cout << "\n";
            }
        }
        return;
    }
    if (m % 2) cout << n + m - 2 << endl;
    else cout << n + m - 3 << endl;
    //cout << n + m - 2 - (1 - (m % 2)) << endl;
    for (int i = 0; i < m; i++) cout << '-';
    cout << endl;
    for (int i = 1; i < n; i++) {
        if (i % 2) {
            for (int j = 1; j <= m / 2 + 1; j++) cout << '+';
            for (int j = m / 2 + 2; j <= m; j++) cout << '-';
        }
        else {
            for (int j = m / 2 + 2; j <= m; j++) cout << '-';
            for (int j = 1; j <= m / 2 + 1; j++) cout << '+';
        }
        cout << endl;
    }
    /*
        ----------------------------
        +++++++++++++++-------------
        -------------+++++++++++++++
        +++++++++++++++-------------
        -------------+++++++++++++++
 
    
    
    */
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    int t; cin >> t; while (t--)
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 5 ms 340 KB in the table A+B is not equal to 27
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 1252 KB Output is correct
2 Correct 19 ms 1124 KB Output is correct
3 Correct 20 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1240 KB in the table A+B is not equal to 45
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 5 ms 340 KB in the table A+B is not equal to 27
5 Halted 0 ms 0 KB -