//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N = 3e5 + 229;
const int M = 1e9 + 7;
const lll M2 = 1e9 + 9;
const lll mod = 998244353;
const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2};
const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1};
const lld eps = 1e-7;
const double pi = acos(-1.0);
bool a[2000][2000];
int k[2000];
void solve() {
int n, m;
cin >> n >> m;
int ans = max(n, m);
for (int i = 0; i < max(n, m); ++i) {
k[i] = 0;
}
if (m > n) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
a[i][j] = 1;
}
}
int now;
for (int i = 0; i < n; ++i) {
now = 0;
for (int j = 0; j < m; ++j) {
if (k[j] + 1 < n / 2 + 1) {
++now;
++k[j];
a[i][j] = 0;
if (now >= m / 2 + 1) {
break;
}
}
}
if (now >= m / 2 + 1) {
++ans;
}
}
} else {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
a[i][j] = 0;
}
}
int now;
for (int j = 0; j < m; ++j) {
now = 0;
for (int i = 0; i < n; ++i) {
if (k[i] + 1 < m / 2 + 1) {
++now;
++k[i];
a[i][j] = 1;
if (now >= n / 2 + 1) {
break;
}
}
}
if (now >= n / 2 + 1) {
++ans;
}
}
}
cout << ans << '\n';
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j]) {
cout << '-';
} else {
cout << '+';
}
}
cout << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
srand(time(0));
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
in the table A+B is not equal to 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
in the table A+B is not equal to 21 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
in the table A+B is not equal to 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
1636 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
1636 KB |
in the table A+B is not equal to 36 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
in the table A+B is not equal to 5 |