#include <bits/stdc++.h>
using namespace std;
bool ans[1005][1005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n, m;
cin >> n >> m;
bool b=0;
if (n>m)
{
swap(n, m);
b=1;
}
int k=n-n/2-1;
int l=min(n, k*m/(m/2+1));
cout << l+m << '\n';
if (l)
{
for (int j=0; j<m; j++)
{
int L=k*j%l, R=k*(j+1)%l;
if (L<R)
for (int i=0; i<l; i++)
ans[i][j]=(L<=i && i<R);
else
for (int i=0; i<l; i++)
ans[i][j]=(L<=i || i<R);
for (int i=l; i<n; i++)
ans[i][j]=0;
}
}
else
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
ans[i][j]=0;
if (b)
{
for (int j=0; j<m; j++)
{
for (int i=0; i<n; i++)
cout << (ans[i][j]?'-':'+');
cout << '\n';
}
}
else
{
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
cout << (ans[i][j]?'+':'-');
cout << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1372 KB |
Output is correct |
2 |
Correct |
22 ms |
1868 KB |
Output is correct |
3 |
Correct |
19 ms |
1848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1416 KB |
Output is correct |
2 |
Correct |
20 ms |
1780 KB |
Output is correct |
3 |
Correct |
17 ms |
1592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
22 ms |
1372 KB |
Output is correct |
6 |
Correct |
22 ms |
1868 KB |
Output is correct |
7 |
Correct |
19 ms |
1848 KB |
Output is correct |
8 |
Correct |
22 ms |
1416 KB |
Output is correct |
9 |
Correct |
20 ms |
1780 KB |
Output is correct |
10 |
Correct |
17 ms |
1592 KB |
Output is correct |
11 |
Correct |
6 ms |
592 KB |
Output is correct |
12 |
Correct |
16 ms |
1600 KB |
Output is correct |
13 |
Correct |
24 ms |
1548 KB |
Output is correct |
14 |
Correct |
13 ms |
1236 KB |
Output is correct |
15 |
Correct |
22 ms |
2264 KB |
Output is correct |
16 |
Correct |
20 ms |
1748 KB |
Output is correct |
17 |
Correct |
10 ms |
1088 KB |
Output is correct |