Submission #689845

#TimeUsernameProblemLanguageResultExecution timeMemory
689845KiriLL1caRed-blue table (IZhO19_stones)C++17
0 / 100
79 ms1388 KiB
#include <bits/stdc++.h> #define sz(x) (int)((x).size()) #define pb push_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fr first #define sc second #define pw(x) (1ll << x) #define bcnt(x) (__builtin_popcountll(x)) using namespace std; typedef long long ll; typedef pair <int, int> pii; template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } inline pair <int, vector <vector <char>>> calc (int n, int m) { set <pii> s; vector <vector <char>> a (n, vector <char> (m, '-')); for (int i = 0; i < m; ++i) s.insert({0, i}); int nn = n / 2 + 1; int mm = m - m / 2 - 1; int ans = m; int uk = 0; while (sz(s) && uk < n) { int T = nn; while (T-- && sz(s)) { auto [c, id] = *s.begin(); s.erase(s.begin()); a[uk][id] = '+'; ++c; if (c + 1 < mm) s.insert({c, id}); } ++uk; ans += !~T; } return {ans, a}; } inline void solve () { int n, m; cin >> n >> m; auto ans = calc(n, m); cout << ans.fr << endl; for (auto i : ans.sc) { for (auto j : i) cout << j; cout << endl; } } signed main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // LOCAL int t = 1; cin >> t; while (t--) solve(); 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...