#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 |
1 |
Incorrect |
1 ms |
212 KB |
Expected integer, but "---" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
320 KB |
Expected integer, but "+++++++++++++++++++++++----------------------" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Expected integer, but "---" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
1252 KB |
Expected integer, but "++++++++++----------+" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
1304 KB |
Expected integer, but "+++++++++++++-----------" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Expected integer, but "---" found |
2 |
Halted |
0 ms |
0 KB |
- |