제출 #579344

#제출 시각아이디문제언어결과실행 시간메모리
579344KoDRed-blue table (IZhO19_stones)C++17
100 / 100
34 ms2288 KiB
#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] = '+'; } } std::cout << best_r + best_c << std::endl; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...