# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681404 | drdilyor | Red-blue table (IZhO19_stones) | C++17 | 28 ms | 4308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef ONPC
#include "t_debug.cpp"
#else
#define debug(...) 42
#endif
using namespace std;
//namespace pbds = __gnu_pbds;
using ll = long long;
const int inf = 1e9;
const ll infl = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
template<typename Cont> int sz(const Cont& cont) { return int(cont.size()); }
const string fileio = "";
constexpr int tests = 1, nmax = 2e5, nlog = __lg(nmax), mod = 1e9+7;
pair<int, vector<string>> construct(int n, int m) {
vector res(n, string(m, '-'));
int k = 0, kr = n - (n/2 + 1);
for (int i = 0; i < n; i++) {
int cnt = m / 2 + 1;
while (cnt-- && k / m < kr) {
res[i][k % m] = '+';
k++;
}
}
int a = 0, b = 0;
for (int i = 0; i < n; i++) {
int ca{}, cb{};
for (int j = 0; j < m; j++) {
if (res[i][j] == '+') ca++;
else cb++;
}
a += ca > cb;
}
for (int i = 0; i < m; i++) {
int ca{}, cb{};
for (int j = 0; j < n; j++) {
if (res[j][i] == '-') ca++;
else cb++;
}
b += ca > cb;
}
return {a + b, res};
}
int solve() {
int n, m;
cin >> n >> m;
if (!cin) return 1;
auto a = construct(n, m);
auto b = construct(m, n);
debug(a.second);
debug(b.second);
if (b.first > a.first) {
a.first = b.first;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char c = b.second[j][i];
a.second[i][j] = c == '+' ? '-' : '+';
}
}
}
cout <<a.first << '\n';
for (auto r : a.second) {
cout << r << '\n';
}
return 0;
}
signed main() {
int t = 1;
#ifdef ONPC
t = 10000;
#else
if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
#endif
cin.tie(0)->sync_with_stdio(0);
if (tests) cin >> t;
while (t-- && cin) {
if (solve()) break;
#ifdef ONPC
cout << "____________________" << endl;
#endif
}
return 0;
}
/*
█████ █████ ███ ████
▒▒███ ▒▒███ ▒▒▒ ▒▒███
███████ ████████ ███████ ████ ▒███ █████ ████ ██████ ████████
███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███ ▒███ ▒▒███ ▒███ ███▒▒███▒▒███▒▒███
▒███ ▒███ ▒███ ▒▒▒ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒
▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███ ▒███
▒▒████████ █████ ▒▒████████ █████ █████ ▒▒███████ ▒▒██████ █████
▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒███ ▒▒▒▒▒▒ ▒▒▒▒▒
███ ▒███
▒▒██████
▒▒▒▒▒▒
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |