제출 #1172952

#제출 시각아이디문제언어결과실행 시간메모리
1172952cpismayilmmdv985Red-blue table (IZhO19_stones)C++20
0 / 100
31 ms1608 KiB
#include <bits/stdc++.h>

using namespace std;

// #define int ll
#define all(x) x.begin(), x.end()
#define len(x) int(x.length())
#define sz(x) int(x.size())
#define F0R(i, l, r) for (int i = l; i <= r; i++)
#define R0F(i, r, l) for (int i = r; i >= l; i--)
#define each(i, x) for (auto &i : x)
#define rep(x) while (x)
#define vec vector
#define ar array
#define max_el *max_element
#define min_el *min_element
#define prq priority_queue
#define grt greater
#define mset multiset
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define skip continue

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve() {
    int N, M;
    cin >> N >> M;
    bool flag = (N > M);

    if (N > M)
        swap(N, M);

    vec<vec<int>> res(M + 5, vec<int> (M + 5));
    vec<int> col(M + 5);
    // 0 -> -
    // 1 -> +
    int target1 = (M & 1 ? ((M + 1) >> 1) : ((M + 2) >> 1));
    int target2 = (N & 1 ? ((N + 1) >> 1) : ((N + 2) >> 1));
    int ans = M;

    F0R (i, 1, N) {
        vec<ar<int, 2>> tmp;

        F0R (j, 1, M) 
            tmp.pb({col[j], j});

        sort(all(tmp));

        if (tmp[target1 - 1][0] + 1 >= target2)
            break;

        F0R (j, 0, target1 - 1) {
            res[i][tmp[j][1]] = 1;
            col[tmp[j][1]]++;
        }

        ans++;
    }

    cout << ans << '\n';

    // if (!flag) {
        F0R (i, 1, N) {
            F0R (j, 1, M) 
                if (!flag)
                    cout << (!res[i][j] ? '-' : '+');
                else 
                    cout << (!res[i][j] ? '+' : '-');

            cout << '\n';
        }
    // } else {
    //     F0R (i, 1, M) {
    //         F0R (j, 1, N)
    //             cout << (!res[i][j] ? '+' : '-');

    //         cout << '\n';
    //     }
    // }

    return;     
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int T = 1;
    cin >> T;

    rep (T-- > 0)
        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...