#include <iostream>
#include <algorithm>
const int N = 1e3 + 5;
int n, m, t;
char ans[N][N], afis[N][N];
void solve() {
char ch='-', rch = '+';
std::cin >> n >> m;
if (n > m) {
std::swap(n, m);
std::swap(ch, rch);
}
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i][j] = ch;
int bulan = m * ((n - 1) / 2);
int i = 0, k = 0;
for (int x = 0; x < bulan; x++) {
ans[i][x % m] = rch, k++;
if (k*2 > m) k = 0, i++;
}
std::cout << m + i << '\n';
if (ch == '+') std::swap(n, m);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
afis[i][j] = ((ch == '-' ? ans[i][j] : ans[j][i]));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
std::cout << afis[i][j];
std::cout << "\n";
}
}
int main() {
std::cin >> t;
while (t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
1516 KB |
Output is correct |
2 |
Correct |
48 ms |
2668 KB |
Output is correct |
3 |
Correct |
46 ms |
2924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
1644 KB |
Output is correct |
2 |
Correct |
45 ms |
2540 KB |
Output is correct |
3 |
Correct |
41 ms |
2156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
56 ms |
1516 KB |
Output is correct |
6 |
Correct |
48 ms |
2668 KB |
Output is correct |
7 |
Correct |
46 ms |
2924 KB |
Output is correct |
8 |
Correct |
54 ms |
1644 KB |
Output is correct |
9 |
Correct |
45 ms |
2540 KB |
Output is correct |
10 |
Correct |
41 ms |
2156 KB |
Output is correct |
11 |
Correct |
15 ms |
620 KB |
Output is correct |
12 |
Correct |
43 ms |
2412 KB |
Output is correct |
13 |
Correct |
45 ms |
2540 KB |
Output is correct |
14 |
Correct |
34 ms |
2028 KB |
Output is correct |
15 |
Correct |
54 ms |
3328 KB |
Output is correct |
16 |
Correct |
41 ms |
2668 KB |
Output is correct |
17 |
Correct |
18 ms |
1772 KB |
Output is correct |