#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n, m;
cin >> n >> m;
bool ans[n][m];
int A = n - (n/2 + 1), sz = m + A, T = 0;
for(int i = A + 1; i <= n; i++)
{
int g = i, t = 0;
g += ((m + 1) / 2 - 1); // case for t = 0
// now for t = 1
int g2 = i;
if(i / 2 <= (n + 1) / 2 - 1)
{
if(m % 2 == 0)
g2 += m / 2 -1;
else
g2 += m / 2;
}
if((i + 1) / 2 <= (n + 1) / 2 - 1)
{
if(m % 2 == 0)
g2 += m / 2 - 1;
else
g2 += m / 2;
}
t = (g <= g2);
g = max(g, g2);
if(g > sz)
sz = g, A = i, T = t;
}
memset(ans, false, sizeof(ans));
for(int i = 0; i < A; i ++)
{
if(i % 2 == 0 && T)
for(int j = 0; j < m / 2 + 1; j++)
ans[i][j] = 1;
else
for(int j = 0; j < m / 2 + 1; j++)
ans[i][m - j - 1] = 1;
}
cout << sz << endl;
for(int i = 0; i < n; i ++)
{
for(int j = 0; j < m; j ++)
cout << (ans[i][j] ? '+' : '-');
cout << endl;
}
}
int main()
{
int t;
cin >> t;
while(t--)
solve();
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... |