#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;
}
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 3 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
in the table A+B is not equal to 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 3 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
1392 KB |
in the table A+B is not equal to 77 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1440 KB |
Output is correct |
2 |
Correct |
18 ms |
1812 KB |
Output is correct |
3 |
Correct |
21 ms |
1636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
in the table A+B is not equal to 3 |
3 |
Halted |
0 ms |
0 KB |
- |