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;
int main() {
int T = 1;
cin >> T;
while(T--) {
int n, m, best_i = 0, best_j = 0;
cin >> n >> m;
for(int i = 0; i <= n; ++i) {
for(int j = 0; j <= m; ++j) {
int plus = i * (m / 2 + 1);
int minus = j * (n / 2 + 1);
if(plus + minus <= n * m) {
bool isGood = 0;
if(!i || !j) isGood = 1;
if(n >= m) {
if(m / 2 + 1 < m - j + 1 || n - (m / 2 + 1) >= n / 2 + 1) {
isGood = 1;
}
} else {
if(n / 2 + 1 < n - i + 1 || m - (n / 2 + 1) >= m / 2 + 1) {
isGood = 1;
}
}
if(isGood) {
if(i + j > best_i + best_j) {
best_i = i; best_j = j;
}
}
}
}
}
cout << best_i + best_j << '\n';
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
if(i <= best_i && j <= m / 2 + 1) {
cout << '+';
} else {
cout << '-';
}
}
cout << '\n';
}
}
}
# | 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... |