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 i64 = long long;
bool check(int red, int blue, int n, int m) {
if (red == 0 || blue == 0) {
return true;
}
int part = std::max(0, (m + 2) / 2 - (m - blue));
int part2 = std::max(0, (n + 2)/ 2 - (n - red));
if (part <= blue) {
int slots = (part * red + blue - 1) / blue;
if (slots + part2 <= red) {
return true;
}
}
return false;
}
void solve() {
int n, m;
std::cin >> n >> m;
int x = 0, y = 0;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (check(i, j, n, m) == true && x + y < i + j) {
x = i;
y = j;
}
}
}
std::cout << x + y << "\n";
int col = 0;
int part = std::max(0, (m + 2) / 2 - (m - y));
for (int i = 0; i < x; i++) {
std::string s;
s.resize(m);
for (int j = 0; j < m; j++) {
s[j] = '-';
}
for (int j = 0; j < part; j++) {
s[col] = '+';
col = (col + 1) % y;
}
for (int j = y; j < m; j++) {
s[j] = '+';
}
std::cout << s << "\n";
}
for (int i = x; i < n; i++) {
std::string s;
s.resize(m);
for (int j = 0; j < m; j++) {
s[j] = '-';
}
std::cout << s << "\n";
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
std::cin >> T;
while (T--) {
solve();
}
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... |