제출 #668403

#제출 시각아이디문제언어결과실행 시간메모리
668403YENGOYANRed-blue table (IZhO19_stones)C++17
38 / 100
45 ms1252 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...