# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
681403 | 2023-01-13T03:11:39 Z | drdilyor | Red-blue table (IZhO19_stones) | C++17 | 22 ms | 2492 KB |
#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 / n < 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; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Wrong answer in test 3 45: 45 < 46 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Wrong answer in test 3 45: 45 < 46 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 22 ms | 1388 KB | Wrong answer in test 97 21: 101 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1364 KB | Output is correct |
2 | Correct | 15 ms | 2492 KB | Output is correct |
3 | Correct | 17 ms | 1872 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 340 KB | Wrong answer in test 3 45: 45 < 46 |
4 | Halted | 0 ms | 0 KB | - |