이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
using ll = long long;
template <class T>
constexpr T infty = std::numeric_limits<T>::max() / 2;
void solve(const int N, const int M) {
const int Nh = N / 2 + 1;
const int Mh = M / 2 + 1;
int best_r = N, best_c = 0;
for (int r = 0; r <= N; ++r) {
for (int c = 1; c <= M; ++c) {
const int a = std::max(Mh - (M - c), 0);
if (N - (a * r + c - 1) / c >= Nh) {
if (best_r + best_c < r + c) {
best_r = r;
best_c = c;
}
}
}
}
vector ans(N, vector(M, '-'));
const int a = std::max(Mh - (M - best_c), 0);
for (int i = 0; i < best_r; ++i) {
for (int j = a * i; j < a * (i + 1); ++j) {
ans[i][j % best_c] = '+';
}
for (int j = best_c; j < M; ++j) {
ans[i][j] = '+';
}
}
for (const auto& v : ans) {
for (const char c : v) {
std::cout << c;
}
std::cout << '\n';
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int test;
std::cin >> test;
while (test--) {
int n, m;
std::cin >> n >> m;
solve(n, m);
}
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... |