#include <bits/stdc++.h>
using namespace std;
/// 123
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
int sw = 0;
if (n < m) swap(n, m), sw = 1;
vector<vector<char>> a(n, vector<char>(m, '+'));
vector<int> cnt(n, m);
int cur = 0;
int k = n / 2 + 1;
int res = n;
for (int i = 0; i < m; i++) {
int ok = 1;
for (int j = 0; j < k; j++) {
if (cnt[cur] - 1 > m - cnt[cur] + 1) {
cnt[cur]--;
a[cur][i] = '-';
} else {
ok = 0;
break;
}
cur++;
cur %= n;
}
res += ok;
}
cout << res << '\n';
for (int i = 0; i < (sw ? m : n); i++) {
for (int j = 0; j < (sw ? n : m); j++) {
cout << (char)(sw ? '-' ^ '+' ^ a[j][i] : a[i][j]);
}
cout << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
1248 KB |
Output is correct |
2 |
Correct |
18 ms |
1620 KB |
Output is correct |
3 |
Correct |
28 ms |
1848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
1364 KB |
Output is correct |
2 |
Correct |
25 ms |
1456 KB |
Output is correct |
3 |
Correct |
22 ms |
1216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
35 ms |
1248 KB |
Output is correct |
6 |
Correct |
18 ms |
1620 KB |
Output is correct |
7 |
Correct |
28 ms |
1848 KB |
Output is correct |
8 |
Correct |
20 ms |
1364 KB |
Output is correct |
9 |
Correct |
25 ms |
1456 KB |
Output is correct |
10 |
Correct |
22 ms |
1216 KB |
Output is correct |
11 |
Correct |
7 ms |
468 KB |
Output is correct |
12 |
Correct |
22 ms |
1552 KB |
Output is correct |
13 |
Correct |
27 ms |
1224 KB |
Output is correct |
14 |
Correct |
12 ms |
1036 KB |
Output is correct |
15 |
Correct |
20 ms |
2272 KB |
Output is correct |
16 |
Correct |
16 ms |
1748 KB |
Output is correct |
17 |
Correct |
7 ms |
980 KB |
Output is correct |