Submission #689781

#TimeUsernameProblemLanguageResultExecution timeMemory
689781KiriLL1caRed-blue table (IZhO19_stones)C++17
0 / 100
29 ms1340 KiB
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fr first
#define sc second
#define pw(x) (1ll << x)
#define bcnt(x) (__builtin_popcountll(x))

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }

inline void solve () {
    int n, m; cin >> n >> m;
    if (n == 1) {
        cout << m << endl;
        cout << string(m, '-') << endl;
    }
    else if (m == 1) {
        cout << n << endl;
        for (int i = 0; i < n; ++i) cout << '+' << endl;
    }
    else {
        vector <string> a (n);
        for (int i = 0; i < n; ++i) {
            a[i] = string(m, ((i & 1) ? '+' : '-'));
        }
        int res = 0;
        for (int i = 0; i < n; ++i) {
            int s = 0;
            for (int j = 0; j < m; ++j) s += (a[i][j] == '+' ? +1 : -1);
            res += s > 0;
        }
        for (int i = 0; i < m; ++i) {
            int s = 0;
            for (int j = 0; j < n; ++j) s += (a[j][i] == '+' ? +1 : -1);
            res += s < 0;
        }
        cout << res << endl;
        for (auto i : a) cout << i << endl;
    }
    cout << endl;
}

signed main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL

    int t = 1; cin >> t;
    while (t--) solve();
    return 0;
}
#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...