제출 #1283084

#제출 시각아이디문제언어결과실행 시간메모리
1283084ayazRed-blue table (IZhO19_stones)C++20
43 / 100
9 ms4416 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

#define ll long long
#define ld long double
#define inf 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define isz(x) (int)(x.size())

const int MXN = 1020;
const ll mod = 998244353;
const char b = '-', r = '+';

char a[MXN][MXN];
void Solve(int tc) {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if (m > n) {
        ans += m;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++) a[i][j] = b;
        int s = (n - 1) / 2, s2 = m - (m - 1) / 2;
        ans += s;
        for (int i = 1; i <= s; i++) {
            if (i & 1) {
                for (int j = 1; j <= s2; j++) a[i][j] = r;
            } else {
                for (int j = m - s2 + 1; j <= m; j++) a[i][j] = r;
            }
        }
        if (n >= 5) {
            if (m & 1) {
                a[n][m] = r;
                for (int j = 1; j <= s2-1; j++) a[n][j] = r;
            } else {
                a[n][m] = a[n][m-1] = r;
                for (int j = 1; j <= s2-2; j++) a[n][j] = r;
            }
            ans++;
        }
    } else {
        ans += n;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++) a[i][j] = r;
        int s = (m - 1) / 2, s2 = n - (n - 1) / 2;
        ans += s;
        for (int j = 1; j <= s; j++) {
            if (j & 1) {
                for (int i = 1; i <= s2; i++) a[i][j] = b;
            } else {
                for (int i = n - s2 + 1; i <= n; i++) a[i][j] = b;
            }
        }
        if (m >= 5) {
            if (n & 1) {
                a[n][m] = b;
                for (int i = 1; i <= s2-1; i++) a[i][m] = b;
            } else {
                a[n][m] = a[n-1][m] = b;
                for (int i = 1; i <= s2-2; i++) a[i][m] = b;
            }
            ans++;
        }
    }
    cout << ans << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) cout << a[i][j];
        cout << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    freopen("err.log", "w", stderr);
#endif
    int t = 1;
    cin >> t;
    for (int tt = 1; tt <= t; ++tt) Solve(tt);
    return 0;
}
#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...