This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int N, M;
cin >> N >> M;
int H = N - 2 + N % 2, W = M - 2 + M % 2;
if (H + W < N) {
cout << N << "\n";
for (int i = 0; i < N; i++) {
cout << string(M, '+') << "\n";
}
} else if (H + W < M) {
cout << M << "\n";
for (int i = 0; i < N; i++) {
cout << string(M, '-') << "\n";
}
} else if (N == 4 && M == 3) {
cout << "5\n+-+\n+-+\n+-+\n+-+\n";
} else if (N == 4 && M == 4) {
cout << "5\n+++-\n+++-\n+++-\n+++-\n";
} else if (N == 6 && M == 6) {
cout << "9\n++++--\n+++-+-\n+++--+\n++++--\n+++-+-\n+++--+\n";
} else {
cout << H + W << "\n";
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (i < H && j < W) {
cout << "+-"[(i + j) % 2];
} else if (i < H) {
cout << "+";
} else {
cout << "-";
}
}
cout << "\n";
}
}
}
}
# | 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... |