이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
#define f1r(i, a, b) for (int i = a; i < b; i++)
#define f0r(i, a) f1r(i, 0, a)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define sz(x) (int) (x).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
void print(vector<vi> a) {
    f0r(i, sz(a)) {
        f0r(j, sz(a[i])) {
            cout << (a[i][j] ? '+' : '-');
        }
        cout << '\n';
    }
}
void solve_case() {
    int n, m; cin >> n >> m;
    int x = ((n + 1) / 2 - 1) * 2;
    int y = ((m + 1) / 2 - 1) * 2;
    vector<vi> a(n, vi(m));
    if (max(n, m) >= x + y) {
        if (n > m) {
            f0r(i, n) {
                f0r(j, m) {
                    a[i][j] = 1;
                }
            }
            cout << n << '\n';
            print(a);
            return;
        } else {
            cout << m << '\n';
            print(a);
            return;
        }
    }
    f0r(i, x) {
        f0r(j, y) {
            a[i][j] = ((i + j) % 2 ? 1 : 0);
        }
    }
    f1r(i, x, n) {
        f0r(j, y) {
            a[i][j] = 0;
        }
    }
    f1r(j, y, m) {
        f0r(i, n) {
            a[i][j] = 1;
        }
    }
    cout << x + y << '\n';
    print(a);
    return;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt; cin >> tt;
    while (tt--) {
        solve_case();
    }
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |