#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 + max(n, m), 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 < n; i++) {
if (c[i] == cur && a[i][col] == '+') {
a[i][col] = '-';
c[i]++;
ccnt++;
if (ccnt > n / 2) {
doneacol = true;
col++;
ccnt = 0;
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 / 2) {
donearow = true;
r++;
ccnt = 0;
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 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
340 KB |
Output is correct |
4 |
Correct |
10 ms |
416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
1320 KB |
Output is correct |
2 |
Correct |
22 ms |
1880 KB |
Output is correct |
3 |
Correct |
27 ms |
2028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
1452 KB |
Output is correct |
2 |
Correct |
26 ms |
1848 KB |
Output is correct |
3 |
Correct |
23 ms |
1620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
6 ms |
340 KB |
Output is correct |
4 |
Correct |
10 ms |
416 KB |
Output is correct |
5 |
Correct |
43 ms |
1320 KB |
Output is correct |
6 |
Correct |
22 ms |
1880 KB |
Output is correct |
7 |
Correct |
27 ms |
2028 KB |
Output is correct |
8 |
Correct |
39 ms |
1452 KB |
Output is correct |
9 |
Correct |
26 ms |
1848 KB |
Output is correct |
10 |
Correct |
23 ms |
1620 KB |
Output is correct |
11 |
Correct |
22 ms |
544 KB |
Output is correct |
12 |
Correct |
26 ms |
1868 KB |
Output is correct |
13 |
Correct |
21 ms |
1996 KB |
Output is correct |
14 |
Correct |
25 ms |
1620 KB |
Output is correct |
15 |
Correct |
25 ms |
2216 KB |
Output is correct |
16 |
Correct |
17 ms |
1744 KB |
Output is correct |
17 |
Correct |
8 ms |
1288 KB |
Output is correct |