#include <bits/stdc++.h>
using namespace std;
string s = "+-";
void go() {
int n, m;
cin >> n >> m;
if (n == 1) {
cout << m << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
return;
}
if (m == 1) {
cout << n << '\n';
for (int i = 0; i < n; i++) cout << s[0] << '\n';
return;
}
if (n == 2) {
cout << m << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
return;
}
if (m == 2) {
cout << n << '\n';
for (int i = 0; i < n; i++) cout << s[0] << s[0] << '\n';
return;
}
if (n == 3) {
cout << m+1 << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[0];
cout << '\n';
}
if (m == 3) {
cout << n+1 << '\n';
for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[1] << '\n';
return;
}
if (n & 1 && m & 1) {
cout << n+m-2 << '\n';
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i == n) cout << s[1];
else if (j == m) cout << s[0];
else cout << s[(i+j)%2];
}
cout << '\n';
}
return;
}
if (n == 4) {
cout << m+1 << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[1];
cout << '\n';
for (int i = 0; i < m; i++) cout << s[0];
cout << '\n';
return;
}
if (m == 4) {
cout << n << '\n';
for (int i = 0; i < n; i++) cout << s[0] << s[0] << s[0] << s[1] << '\n';
return;
}
if (n % 2 == 0 && m % 2 == 0) {
cout << n+m-4 << '\n';
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i == n || i == n-1) cout << s[1];
else if (j == m || j == m-1) cout << s[0];
else cout << s[(i+j)%2];
}
cout << '\n';
}
return;
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie();
cout.tie();
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
int T;
cin >> T;
while(T--) go();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Wrong answer |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
1248 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
1296 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |