#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';
return;
}
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();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
2 ms |
300 KB |
in the table A+B is not equal to 18 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1288 KB |
Output is correct |
2 |
Correct |
25 ms |
1132 KB |
Output is correct |
3 |
Correct |
17 ms |
1060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1260 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
2 ms |
300 KB |
in the table A+B is not equal to 18 |