답안 #1032023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032023 2024-07-23T10:16:27 Z phoenix Red-blue table (IZhO19_stones) C++17
100 / 100
31 ms 2388 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define cerr cout
#else 
#define cerr if (false) cout
#endif

void solve() {
    int n, m;
    cin >> n >> m;
    int ra = 0, rb = m;
    for (int a = 1; a <= n; a++) {
        int l = 0, r = m + 1;
        while (r - l > 1) {
            int b = (l + r) / 2;
            int k = max(0, m / 2 + 1 - m + b);
            if ((n - n / 2 - 1) * b >= k * a)
                l = b;
            else 
                r = b;
        }
        if (a + l > ra + rb)
            ra = a, rb = l;
    }
    cerr << ra << ' ' << rb << '\n';
    char arr[n][m];
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++)
        arr[i][j] = '-';
    for (int i = 0; i < ra; i++)
        for (int j = rb; j < m; j++)
            arr[i][j] = '+';
    int k = max(0, m / 2 + 1 - m + rb);
    int l = 0;
    for (int i = 0; i < ra; i++) {
        for (int j = 0; j < k; j++) {
            arr[i][l] = '+';
            l = (l + 1) % rb;
        }
    }
    cout << ra + rb << '\n';
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            cout << arr[i][j];
        cout << '\n';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int number_of_tests;
    cin >> number_of_tests;
    for (int current_test = 0; current_test < number_of_tests; current_test++) {
        cerr << "++++++++++++ #" << current_test << " ++++++++++++++++\n";
        solve();
        cerr << "++++++++++++++++++++++++++++++++\n\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1368 KB Output is correct
2 Correct 15 ms 1884 KB Output is correct
3 Correct 27 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1368 KB Output is correct
2 Correct 14 ms 1628 KB Output is correct
3 Correct 13 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 18 ms 1368 KB Output is correct
6 Correct 15 ms 1884 KB Output is correct
7 Correct 27 ms 1884 KB Output is correct
8 Correct 23 ms 1368 KB Output is correct
9 Correct 14 ms 1628 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 15 ms 1628 KB Output is correct
13 Correct 15 ms 1372 KB Output is correct
14 Correct 14 ms 1112 KB Output is correct
15 Correct 31 ms 2388 KB Output is correct
16 Correct 14 ms 1880 KB Output is correct
17 Correct 6 ms 860 KB Output is correct