#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, m; cin >> n >> m;
if (min(m, n) <= 3) {
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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
1228 KB |
Output is correct |
2 |
Correct |
19 ms |
1204 KB |
Output is correct |
3 |
Correct |
19 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
1236 KB |
in the table A+B is not equal to 45 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 5 |
3 |
Halted |
0 ms |
0 KB |
- |