Submission #681404

#TimeUsernameProblemLanguageResultExecution timeMemory
681404drdilyorRed-blue table (IZhO19_stones)C++17
100 / 100
28 ms4308 KiB
#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)

stones.cpp: In function 'int solve()':
stones.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
stones.cpp:56:5: note: in expansion of macro 'debug'
   56 |     debug(a.second);
      |     ^~~~~
stones.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
stones.cpp:57:5: note: in expansion of macro 'debug'
   57 |     debug(b.second);
      |     ^~~~~
stones.cpp: In function 'int main()':
stones.cpp:81:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:81:74: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |     if (fileio.size()) {freopen((fileio+".in").c_str(),"r",stdin);freopen((fileio+".out").c_str(),"w",stdout);}
      |                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...