#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 & 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 % 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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 4: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1228 KB |
Output is correct |
2 |
Correct |
18 ms |
1068 KB |
Output is correct |
3 |
Correct |
18 ms |
1080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1216 KB |
Wrong answer in test 4 4: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 4: 4 < 5 |