이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define cerr cout
#else
#define cerr if (false) cout
#endif
void solve() {
int n, m;
cin >> n >> m;
int ra = 0, rb = m;
for (int a = 1; a <= n; a++) {
int l = 0, r = m + 1;
while (r - l > 1) {
int b = (l + r) / 2;
int k = max(0, m / 2 + 1 - m + b);
if ((n - n / 2 - 1) * b >= k * a)
l = b;
else
r = b;
}
if (a + l > ra + rb)
ra = a, rb = l;
}
cerr << ra << ' ' << rb << '\n';
char arr[n][m];
for (int i = 0; i < n; i++) for (int j = 0; j < m; j++)
arr[i][j] = '-';
for (int i = 0; i < ra; i++)
for (int j = rb; j < m; j++)
arr[i][j] = '+';
int k = max(0, m / 2 + 1 - m + rb);
int l = 0;
for (int i = 0; i < ra; i++) {
for (int j = 0; j < k; j++) {
arr[i][l] = '+';
l = (l + 1) % rb;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
cout << arr[i][j];
cout << '\n';
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int number_of_tests;
cin >> number_of_tests;
for (int current_test = 0; current_test < number_of_tests; current_test++) {
cerr << "++++++++++++ #" << current_test << " ++++++++++++++++\n";
solve();
cerr << "++++++++++++++++++++++++++++++++\n\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... |