#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
#define int ll
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int tc; cin >> tc;
while(tc--){
int n, m; cin >> n >> m;
char a[n][m];
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++)a[i][j] = '+';
}
bool swit = 0;
if(n < m){
swap(n, m);
swit = 1;
}
vector <int> cnt(n, m);
bool cont = 1;
int r =0, c = 0;
ll ans = n;
while(cont){
int tmp = r;
for(int i = 1 ; i <= n / 2 + 1 ; i++){
cnt[tmp]--;
tmp++;
if(tmp >= n)tmp = 0;
}
tmp = r;
for(int i = 1 ; i <= n / 2 + 1 ; i++){
if(cnt[tmp] <= m / 2)cont = 0;
tmp++;
if(tmp >= n)tmp = 0;
}
if(!cont)break;
ans++;
for(int i = 1 ; i <= n ; i++){
if(swit)a[c][r] = '-';
else a[r][c] = '-';
r++;
if(r >= n)r = 0;
}
c++;
}
cout << ans << endl;
if(swit){
for(int i = 0 ; i < m ; i++){
for(int j = 0 ; j < n ; j++){
cout << (a[i][j] == '-' ? '+' : '-');
}
cout << endl;
}
}
else{
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < m ; j++){
cout << a[i][j];
}
cout << endl;
}
}
}
return 0;
}
# | 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... |