#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, m; cin >> n >> m;
if (min(m, n) <= 3 || (n <= 4 && m <= 4)) {
if (n + (m + 1) / 2 - 1 > m + (n + 1) / 2 - 1) {
cout << n + (m + 1) / 2 - 1 << endl;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (j <= m / 2 + 1) cout << '+';
else cout << '-';
}
cout << "\n";
}
}
else {
cout << m + (n + 1) / 2 - 1 << endl;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i <= n / 2 + 1) cout << '-';
else cout << '+';
}
cout << "\n";
}
}
return;
}
cout << n + m - 2 - (1 - (m % 2)) << endl;
for (int i = 0; i < m; i++) cout << '-';
cout << endl;
for (int i = 1; i < n; i++) {
if (i % 2) {
for (int j = 1; j <= m / 2 + 1; j++) cout << '+';
for (int j = m / 2 + 2; j <= m; j++) cout << '-';
}
else {
for (int j = m / 2 + 2; j <= m; j++) cout << '-';
for (int j = 1; j <= m / 2 + 1; j++) cout << '+';
}
cout << endl;
}
/*
----------------------------
+++++++++++++++-------------
-------------+++++++++++++++
+++++++++++++++-------------
-------------+++++++++++++++
*/
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL), cout.tie(NULL);
int t; cin >> t; while (t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
5 ms |
340 KB |
in the table A+B is not equal to 27 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1304 KB |
Output is correct |
2 |
Correct |
19 ms |
1108 KB |
Output is correct |
3 |
Correct |
18 ms |
1076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
1316 KB |
in the table A+B is not equal to 45 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
5 ms |
340 KB |
in the table A+B is not equal to 27 |
5 |
Halted |
0 ms |
0 KB |
- |