제출 #331105

#제출 시각아이디문제언어결과실행 시간메모리
331105EnkhmunkhRed-blue table (IZhO19_stones)C++14
0 / 100
38 ms1512 KiB
#include <bits/stdc++.h>
using namespace std;
void solution () {
    int n, m;
    cin >> n >> m;
    char arr[n][m];
    if (n > m) {
        cout << m + m/2 << "\n";
        for (int i = 0; i < n; i++) {
            for (int j = 0, a = m/2-1; j < m; j++) {
                if (a != 0) {
                    arr[i][j] = '-';
                    a--;
                }else {
                    arr[i][j] = '+';
                }
                cout << arr[i][j];
            }
            cout << "\n";
        }
    }else {
        int a;
        if (n % 2 == 0){
            cout << m+n/2-1 << "\n";
            a = n/2-1;
        } else {
            cout << m+n/2 << "\n";
            a = n/2;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a != 0) {
                    arr[i][j] = '+';
                }else {
                    arr[i][j] = '-';
                }
                cout << arr[i][j];
            }
            if (a != 0) {
                a--;
            }
            cout << "\n";
        }
    }
}
int main () {
    ios::sync_with_stdio(false);
	cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) solution();
}
#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...