#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int mod = 1e9 + 7;
const int inf = 2e18;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int ttt;
cin >> ttt;
while (ttt--) {
int n, m;
cin >> n >> m;
bool inv = false;
if (n > m) {
inv = true;
swap(n, m);
}
vector<string> a(n, string(m, '-'));
int plus_in_col = (n - 1) / 2;
int pos_rows = (plus_in_col * m) / (m / 2 + 1);
int i = 0;
for (int j = 0; j < m; j++) {
for (int q = 0; q < plus_in_col; q++) {
a[i][j] = '+';
i = (i + 1) % pos_rows;
}
}
cout << pos_rows + m << '\n';
if (inv) {
swap(n, m);
vector<string> b(n, string(m, '-'));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
b[i][j] = a[j][i] == '-' ? '+' : '-';
}
}
a = b;
}
for (int i = 0; i < n; i++) {
cout << a[i] << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1376 KB |
Output is correct |
2 |
Correct |
5 ms |
2132 KB |
Output is correct |
3 |
Correct |
7 ms |
3368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1376 KB |
Output is correct |
2 |
Correct |
4 ms |
1632 KB |
Output is correct |
3 |
Correct |
4 ms |
1252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
8 ms |
1376 KB |
Output is correct |
6 |
Correct |
5 ms |
2132 KB |
Output is correct |
7 |
Correct |
7 ms |
3368 KB |
Output is correct |
8 |
Correct |
4 ms |
1376 KB |
Output is correct |
9 |
Correct |
4 ms |
1632 KB |
Output is correct |
10 |
Correct |
4 ms |
1252 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
5 ms |
2620 KB |
Output is correct |
13 |
Correct |
5 ms |
2064 KB |
Output is correct |
14 |
Correct |
4 ms |
1336 KB |
Output is correct |
15 |
Correct |
4 ms |
2388 KB |
Output is correct |
16 |
Correct |
3 ms |
1740 KB |
Output is correct |
17 |
Correct |
3 ms |
1620 KB |
Output is correct |