#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)
ll n, t, b[N], m, T;
char a[5000][5000];
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> T;
while(T--) {
cin >> n >> m;
for(int i = 1;i <= m; i++) {
b[i] = n;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
a[i][j] = '-';
}
}
int cnt = 1, ans = 0;
for(int i = 1; i <= n; i++) {
t = cnt;
for(int j = cnt; j <= m; j++) {
if(b[j] > (n + 1) / 2) {
a[i][j] = '+';
b[j]--;
t = j + 1;
}
}
if(t == m + 1) t = 1;
cnt = t;
}
for(int i= 1;i<=n;i++) {
t = 0;
for(int j = 1; j <= m; j++) {
if(a[i][j] == '+') t++;
else t--;
}
if(t > 0) ans++;
}
cout << ans + m <<'\n';
for(int i =1;i<=n;i++){
for(int j=1;j<=m;j++) {
cout << a[i][j];
}
cout << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |