#include <iostream>
#include <algorithm>
using namespace std;
char s[1002][1002];
int main()
{
int t;
cin >> t;
while (t--)
{
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
s[i][j] = '+';
int A, B, ans;
if (n > m) {
A = n; B = 0; ans = n;
}
else {
A = 0; B = m; ans = m;
}
for (int a = 1; a <= n; a++)
{
int k = (n + 1) / 2 - (n - a);
if (k == 0)
{
if (a + m > ans)
{
ans = a + m; A = a; B = m;
}
continue;
}
int b = (m / 2) * a / k;
while (k * b / a + ((k * b) % a ? 1 : 0) > m / 2)
b--;
if (a + b > ans)
{
ans = a + b; A = a; B = b;
}
}
int i = 0, j = 0;
int k = (n + 1) / 2 - (n - A);
while (i < B)
{
int cnt = 0;
while (cnt < k)
{
s[j][i] = '-';
j++;
if (j >= A)
j = 0;
cnt++;
}
i++;
}
for (int i = 0; i < B; i++)
for (int j = A; j < n; j++)
s[j][i] = '-';
cout << ans << '\n';
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
cout << s[i][j];
cout << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
in the table A+B is not equal to 22 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
1388 KB |
in the table A+B is not equal to 539 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
1516 KB |
in the table A+B is not equal to 169 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 6 |