Submission #530854

#TimeUsernameProblemLanguageResultExecution timeMemory
530854abc864197532Red-blue table (IZhO19_stones)C++17
100 / 100
24 ms2252 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mp make_pair #define eb emplace_back #define pb push_back #define pii pair<int,int> #define X first #define Y second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void abc() {cout << endl;} template <typename T, typename ...U> void abc(T i, U ...j) { cout << i << ' ', abc(j...); } template <typename T> void printv(T l, T r) { for (; l != r; ++l) cout << *l << " \n"[l + 1 == r]; } #ifdef Doludu #define test(x...) abc("[" + string(#x) + "]", x); #define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #else #define test(x...) void(0) #define owo ios::sync_with_stdio(false) #endif const int N = 200000; int main () { owo; int t; cin >> t; while (t--) { int n, m; cin >> n >> m; bool flag = false; if (n > m) flag = true, swap(n, m); int num = 0, ans = -1, now = m; vector <int> cnt(m, 0); for (int i = 0, j = 0; i <= n; ++i) { if (ans < now + i) ans = now + i, num = i; if (i == n) break; for (int c = 0; c < (m + 2) / 2; ++c, j = (j + 1) % m) { now -= cnt[j] < (n + 1) / 2; cnt[j]++; now += cnt[j] < (n + 1) / 2; } } cout << ans << endl; vector <string> s(n); for (int i = 0, j = 0; i < n; ++i) { string now = string(m, '-'); if (i < num) { for (int c = 0; c < (m + 2) / 2; ++c, j = (j + 1) % m) { now[j] = '+'; } } s[i] = now; } if (flag) { for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) cout << (s[j][i] == '+' ? '-' : '+'); cout << '\n'; } } else { for (int i = 0; i < n; ++i) cout << s[i] << '\n'; } } }
#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...