제출 #676612

#제출 시각아이디문제언어결과실행 시간메모리
676612Halym2007Red-blue table (IZhO19_stones)C++11
0 / 100
21 ms1316 KiB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define cont continue;
#define sz size()
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 100005;

void solve();
ll a1, a2, t, n, m;
int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 	cin >> t;
    while ( t-- ) {
        cin >> n >> m;
        if (n == 1 or m == 1) {
            if (n >= m) {
                cout << n << "\n";
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= m; ++j) {
                        cout << "+";
                    }
                    cout << "\n";
                }
            }
            else {
                cout << m << "\n";
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= m; ++j) {
                        cout << "-";
                    }
                    cout << "\n";
                }
            }
        }
        else if (n >= m) {
            cout << n + ((m - 1) / 2) << "\n";
            for (int i = 1; i <= n; ++i) {
                a1 = (n / 2) + 1;
                for (int j = 1; j <= m; ++j) {
                    if (a1 >= 1) {
                        cout << "+";
                        a1--;
                    }
                    else cout << "-";   
                }
                cout << "\n";
            }
        }
        else {
            a1 = (n / 2) + 1;
            cout << m + ((n - 1) / 2) << "\n";
            for (int i = 1; i <= n; ++i) {
                if (a1 >= 1) {
                    for (int j = 1; j <= m; ++j) cout << "-";
                    a1--;
                }
                else {
                    for (int j = 1; j <= m; ++j) cout << "+";
                }
                cout << "\n";
            }
        }

        cout << "\n";
    }
}
#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...