#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 {
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";
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong answer in test 4 3: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1372 KB |
Output is correct |
2 |
Correct |
14 ms |
1116 KB |
Output is correct |
3 |
Correct |
20 ms |
1112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1368 KB |
Wrong answer in test 4 4: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Wrong answer in test 4 4: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |