/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
int t,n,m,ans,rev;
char a[1003][1003],sum[1003];
int main()
{
cin>>t;
while(t--)
{
rev=0;
cin>>n>>m;
if(m<n)
{
swap(m,n);
rev=1;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
a[i][j]='-';
int k=min(((m*(n-(n/2+1)))/(m/2+1)),n);
ans=m+k;
int l=0,r=n/2-n+k;
if(k)
{
if(r>=0)
for(int j=1;j<=m;j++)
{
l++;
r++;
for(int i=1;i<=k;i++)
if(((i<l || i>r) && l<=r) || (l>r && i<l && i>r))
a[i][j]='+';
l+=n/2-n+k;
r+=n/2-n+k;
l%=k;
r%=k;
}
else
for(int j=1;j<=m;j++)
for(int i=1;i<=k;i++)
a[i][j]='+';
}
printf("%d\n",ans);
if(!rev)
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
printf("%c",a[i][j]);
printf("\n");
}
else
{
for(int j=1;j<=m;j++)
{
for(int i=1;i<=n;i++)
{
if(a[i][j]=='+')
a[i][j]='-';
else
a[i][j]='+';
printf("%c",a[i][j]);
}
printf("\n");
}
}
}
return 0;
}
/*
2
1 3
3 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
1400 KB |
Output is correct |
2 |
Correct |
50 ms |
2008 KB |
Output is correct |
3 |
Correct |
48 ms |
1916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
1408 KB |
Output is correct |
2 |
Correct |
45 ms |
1824 KB |
Output is correct |
3 |
Correct |
43 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
504 KB |
Output is correct |
5 |
Correct |
57 ms |
1400 KB |
Output is correct |
6 |
Correct |
50 ms |
2008 KB |
Output is correct |
7 |
Correct |
48 ms |
1916 KB |
Output is correct |
8 |
Correct |
58 ms |
1408 KB |
Output is correct |
9 |
Correct |
45 ms |
1824 KB |
Output is correct |
10 |
Correct |
43 ms |
1656 KB |
Output is correct |
11 |
Correct |
19 ms |
632 KB |
Output is correct |
12 |
Correct |
51 ms |
1628 KB |
Output is correct |
13 |
Correct |
49 ms |
1784 KB |
Output is correct |
14 |
Correct |
35 ms |
1272 KB |
Output is correct |
15 |
Correct |
53 ms |
2296 KB |
Output is correct |
16 |
Correct |
44 ms |
1912 KB |
Output is correct |
17 |
Correct |
20 ms |
1116 KB |
Output is correct |