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 <iostream>
#include <vector>
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
bool valid(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(valid(i, j, n, m) == true && x + y < i + j) {
x = i;
y = j;
}
std::cout << x + y << '\n';
int ptr = 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[ptr] = '+';
ptr = (ptr + 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() {
int t;
std::cin >> t;
for(int testcase = 1; testcase <= t; testcase++)
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... |