#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define ppb pop_back
#define clr clear
#define len size()
#define beg begin()
#define end end()
#define ins insert
#define f first
#define s second
#define y1 y123456789
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
using namespace __gnu_pbds;
typedef tree < int, null_type, greater_equal < int >,
rb_tree_tag, tree_order_statistics_node_update > ordered_set;
int t, n, m;
const int MAXN = 1020;
char a[MAXN][MAXN];
int main()
{
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
fastio;
cin >> t;
while (t--)
{
cin >> n >> m;
if (n & 1)
{
if (m & 1)
{
if (n > m)
{
for (int j = 1; j <= m / 2 + 1; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '+';
for (int j = m / 2 + 2; j <= m; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '-';
}
else
{
for (int j = 1; j <= m; ++j)
for (int i = 1; i <= n / 2 + 1; ++i)
a[i][j] = '-';
for (int j = 1; j <= m; ++j)
for (int i = n / 2 + 2; i <= n; ++i)
a[i][j] = '+';
}
cout << max(n + m / 2, m + n / 2);
}
else
{
if (m + n / 2 > n + (m - 1) / 2)
{
for (int j = 1; j <= m; ++j)
for (int i = 1; i <= n / 2 + 1; ++i)
a[i][j] = '-';
for (int j = 1; j <= m; ++j)
for (int i = n / 2 + 2; i <= n; ++i)
a[i][j] = '+';
}
else
{
for (int j = 1; j <= m / 2 + 1; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '+';
for (int j = m / 2 + 2; j <= m; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '-';
}
cout << max(m + n / 2, n + (m - 1) / 2);
}
}
else
{
if (m & 1)
{
if (n + m / 2 < m + (n - 1) / 2)
{
for (int j = 1; j <= m; ++j)
for (int i = 1; i <= n / 2 + 1; ++i)
a[i][j] = '-';
for (int j = 1; j <= m; ++j)
for (int i = n / 2 + 2; i <= n; ++i)
a[i][j] = '+';
}
else
{
for (int j = 1; j <= m / 2 + 1; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '+';
for (int j = m / 2 + 2; j <= m; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '-';
}
cout << max(n + m / 2, m + (n - 1) / 2);
}
else
{
if (n + (m - 1) / 2 < m + (n - 1) / 2)
{
for (int j = 1; j <= m; ++j)
for (int i = 1; i <= n / 2 + 1; ++i)
a[i][j] = '-';
for (int j = 1; j <= m; ++j)
for (int i = n / 2 + 2; i <= n; ++i)
a[i][j] = '+';
}
else
{
for (int j = 1; j <= m / 2 + 1; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '+';
for (int j = m / 2 + 2; j <= m; ++j)
for (int i = 1; i <= n; ++i)
a[i][j] = '-';
}
cout << max(n + (m - 1) / 2, m + (n - 1) / 2);
}
}
cout << '\n';
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
cout << a[i][j];
cout << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
2 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
1416 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1360 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 |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Incorrect |
2 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |