#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
using namespace std;
typedef long long ll;
typedef long double ld;
#define ff first
#define ss second
ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 1007;
ll n, m, k;
char a[N][N];
ll c[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> ttt;
while (ttt--) {
cin >> n >> m;
fill(c, c + n, 0);
if (n > m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = '+';
}
}
int ans = n;
int col = 0;
int cur = 0;
int ccnt = 0;
while (cur < (m + 1) / 2 - 1 && col < m) {
bool doneacol = false;
for (int i = 0; i < m; i++) {
if (c[i] == cur && a[i][col] == '+') {
a[i][col] = '-';
c[i]++;
ccnt++;
if (ccnt > (m + 1) / 2) {
doneacol = true;
col++;
ans++;
break;
}
}
}
if (!doneacol) {
cur++;
}
}
cout << ans << endl;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << a[i][j];
}
cout << endl;
}
}
else {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = '-';
}
}
int ans = m;
int r = 0;
int cur = 0;
int ccnt = 0;
while (cur < (n + 1) / 2 - 1 && r < n) {
bool donearow = false;
for (int j = 0; j < m; j++) {
if (c[j] == cur && a[r][j] == '-') {
a[r][j] = '+';
c[j]++;
ccnt++;
if (ccnt > (m + 1) / 2) {
donearow = true;
r++;
ans++;
break;
}
}
}
if (!donearow) {
cur++;
}
}
cout << ans << endl;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << a[i][j];
}
cout << endl;
}
}
}
return 0;
}
/// ---- - -------- ------ -------- -- - - -
/// Just a reminder. Ubuntu password is I O I
/// ---- - -------- ------ -------- -- - - -
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
340 KB |
in the table A+B is not equal to 48 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
50 ms |
1372 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
1356 KB |
in the table A+B is not equal to 48 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 6 |
3 |
Halted |
0 ms |
0 KB |
- |