Submission #142943

# Submission time Handle Problem Language Result Execution time Memory
142943 2019-08-12T08:35:48 Z model_code Red-blue table (IZhO19_stones) C++17
100 / 100
77 ms 2680 KB
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
       
        
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } 
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second; return _out; }
template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define rank rank228
#define y1 y1228                                                         
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
const string FILENAME = "input";
const int MAXN = 1005;

char c[2] = {'-', '+'};
int n, m;
char ans[MAXN][MAXN];
int cur[MAXN];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //read(FILENAME);
    int t;
    cin >> t;
    for (int it = 0; it < t; it++) {
        cin >> n >> m;
        bool inv = false;
        if (n > m) {
            swap(n, m);
            inv = true;
        }
        for (int i = 0; i < n; i++) {
            cur[i] = 0;
            for (int j = 0; j < m; j++) {
                ans[i][j] = c[0];
            }
        }
        int t = n / 2;
        while (t <= n - t) {
            t++;
        }
        int rem = n - t;
        int need = m / 2;
        while (need <= m - need) {
            need++;
        }
        //cout << need << endl;
        //cout << rem << endl;
        int res = 0;
        for (int cnst = n; cnst >= 0; cnst--) {
            if (cnst * need <= rem * m) {
                res = cnst;
                break;
            }
        }
       // cout << res << endl;
        for (int i = 0; i < m; i++) {
            vector<pair<int, int> > st;
            for (int j = 0; j < res; j++) {
                st.pb({cur[j], j});
            }
            sort(all(st));
            for (int j = 0; j < rem; j++) {
                ans[st[j].second][i] = c[1];
                cur[st[j].second]++;
            }
        }
        cout << m + res << '\n';
        if (inv) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++) {
                    cout << (char)(ans[j][i] ^ c[0] ^ c[1]);
                }
                cout << '\n';
            }
        } else {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    cout << ans[i][j];
                }
                cout << '\n';
            }
        }
    }
    return 0; 
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 1508 KB Output is correct
2 Correct 67 ms 2040 KB Output is correct
3 Correct 64 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 1532 KB Output is correct
2 Correct 60 ms 1856 KB Output is correct
3 Correct 57 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 73 ms 1508 KB Output is correct
6 Correct 67 ms 2040 KB Output is correct
7 Correct 64 ms 2040 KB Output is correct
8 Correct 64 ms 1532 KB Output is correct
9 Correct 60 ms 1856 KB Output is correct
10 Correct 57 ms 1628 KB Output is correct
11 Correct 17 ms 632 KB Output is correct
12 Correct 56 ms 1664 KB Output is correct
13 Correct 56 ms 1656 KB Output is correct
14 Correct 44 ms 1272 KB Output is correct
15 Correct 77 ms 2680 KB Output is correct
16 Correct 57 ms 1912 KB Output is correct
17 Correct 24 ms 1144 KB Output is correct