답안 #502604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502604 2022-01-06T10:28:40 Z stanislavpolyn Red-blue table (IZhO19_stones) C++17
0 / 100
24 ms 1412 KB
#include <bits/stdc++.h>

#define fr(i, a, b) for(int i = (a); i <= (b); ++i)
#define rf(i, a, b) for(int i = (a); i >= (b); --i)
#define fe(x, y) for(auto& x : y)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pw(x) (1LL << (x))

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

template<typename T>
bool umn(T& a, T b) { return (a > b ? (a = b, 1) : 0); }
template<typename T>
bool umx(T& a, T b) { return (a < b ? (a = b, 1) : 0); }

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>
using ve = vector<T>;

const int N = 1e3 + 5;

int n, m;
char a[N][N];
int cntR[N];
int cntB[N];

void solve() {
    cin >> n >> m;

    fr(i, 1, n) cntR[i] = 0;
    fr(i, 1, m) cntB[i] = 0;

    int needR = m / 2 + 1;
    int needB = n / 2 + 1;

    fr(i, 1, n) {
        fr(j, 1, m) {
            if(cntR[i] < needR && cntB[j] + (n - i) >= needB) {
                cntR[i]++;
                a[i][j] = 'R';
            } else {
                a[i][j] = 'B';
                cntB[j]++;
            }
        }
    }

    int score = 0;
    fr(i, 1, n) score += cntR[i] >= needR;
    fr(i, 1, m) score += cntB[i] >= needB;

    cout << score << "\n";
    fr(i, 1, n) {
        fr(j, 1, m) {
            cout << (a[i][j] == 'R' ? '+' : '-');
        }
        cout << "\n";
    }
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 396 KB Wrong answer in test 2 1: 1 < 2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1412 KB Wrong answer in test 97 21: 69 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 1348 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2