Submission #197155

#TimeUsernameProblemLanguageResultExecution timeMemory
197155IOrtroiiiRed-blue table (IZhO19_stones)C++14
100 / 100
67 ms2424 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int N, M; cin >> N >> M; bool swapped = false; if (N > M) { swap(N, M); swapped = true; } int upHalfN = (N / 2) + 1; int upHalfM = (M / 2) + 1; vector<vector<char>> ans(N, vector<char>(M, '-')); int nRow; for (nRow = N; nRow >= 0; --nRow) { if (nRow * upHalfM <= M * (N - upHalfN)) { break; } } vector<int> cnts(nRow, 0); for (int i = 0; i < M; ++i) { vector<pair<int, int>> cnds; for (int j = 0; j < nRow; ++j) { cnds.emplace_back(cnts[j], j); } sort(cnds.begin(), cnds.end()); cnds.resize(N - upHalfN); for (auto v : cnds) { int r = v.second; ans[r][i] = '+'; ++cnts[r]; } } cout << M + nRow << "\n"; if (swapped) { for (int i = 0; i < M; ++i) { for (int j = 0; j < N; ++j) { cout << char(ans[j][i] ^ '+' ^ '-'); } cout << "\n"; } } else { for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) { cout << ans[i][j]; } cout << "\n"; } } } int main() { ios_base::sync_with_stdio(false); int T; cin >> T; while (T--) { solve(); } }
#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...