#include <iostream>
using namespace std;
int t;
int main()
{
cin >> t;
while (t--)
{
int m, n;
cin >> m >> n;
if (m == n)
{
if (m & 1)
cout << m + n / 2 << '\n';
else
cout << m + n / 2 - 1 << '\n';
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n / 2 + 1; j++)
cout << '+';
for (int j = n / 2 + 2; j <= n; j++)
cout << '-';
cout << '\n';
}
}
else if (n > m) /// mai multe coloane decat randuri
{
int sum = n;
if (m & 1)
sum += m / 2;
else
sum += m / 2 - 1;
cout << sum << '\n';
for (int i = 1; i <= m / 2 + 1; i++)
{
for (int j = 1; j <= n; j++)
cout << '-';
cout << '\n';
}
for(int i = m/2+2 ; i <= m ; i++)
{
for (int j = 1; j <= n; j++)
cout << '+';
cout << '\n';
}
}
else if (m > n) /// mai multe randuri decat coloane
{
int sum = m;
if (n & 1)
sum += n / 2;
else
sum += n / 2 - 1;
cout << sum << '\n';
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n / 2 + 1; j++)
cout << '+';
for (int j = n / 2 + 2; j <= n; j++)
cout << '-';
cout << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Incorrect |
5 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
1516 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1388 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
268 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Incorrect |
5 ms |
364 KB |
Wrong answer in test 5 29: 31 < 32 |