This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int t, n, m;
bool ans[N][N];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
bool swp = 0;
if (n > m) {
swap(n, m);
swp = 1;
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) ans[i][j] = 0;
}
int sum = m, mx = (n - 1) / 2;
int off = -1, pos = m / 2 + 1;
for (int i = 1; i < m; ++i) {
if (min(n, (pos + i - 1) / i) <= mx) {
off = i; break;
}
}
int idx = 0;
for (int i = 0; i < min(n, m * mx / (m / 2 + 1)); ++i) {
for (int j = idx; j < idx + m / 2 + 1; ++j) {
ans[i][j % m] = 1;
}
++sum;
idx += off;
}
cout << sum << '\n';
if (swp) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (ans[i][j]) cout << '-';
else cout << '+';
} cout << '\n';
}
} else {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (ans[i][j]) cout << '+';
else cout << '-';
} cout << '\n';
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |