답안 #561840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
561840 2022-05-13T16:03:48 Z Stickfish Red-blue table (IZhO19_stones) C++17
100 / 100
45 ms 1568 KB
#include <iostream>
#include <vector>
using namespace std;

pair<int, vector<vector<bool>>> solve_smalln(int n, int m) {
    int remilia = (n - 1) / 2;
    int flandre = m / 2 + 1;
    int rowcnt = 1ll * remilia * m / flandre;
    vector<vector<bool>> ans(n, vector<bool>(m, 0));
    int currow = 0;
    for (int j = 0; j < m; ++j) {
        for (int t = 0; t < remilia; ++t) {
            ans[currow++][j] = 1;
            currow %= rowcnt;
        }
    }
    return {m + rowcnt, ans};
}

void solve() {
    int n, m;
    cin >> n >> m;
    if (n <= m) {
        auto [cnt, ans] = solve_smalln(n, m);
        cout << cnt << '\n';
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (ans[i][j])
                    cout << '+';
                else
                    cout << '-';
            }
            cout << '\n';
        }
    } else {
        auto [cnt, ans] = solve_smalln(m, n);
        cout << cnt << '\n';
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (!ans[j][i])
                    cout << '+';
                else
                    cout << '-';
            }
            cout << '\n';
        }
    }
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 1308 KB Output is correct
2 Correct 33 ms 1268 KB Output is correct
3 Correct 32 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1328 KB Output is correct
2 Correct 28 ms 1232 KB Output is correct
3 Correct 26 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 45 ms 1308 KB Output is correct
6 Correct 33 ms 1268 KB Output is correct
7 Correct 32 ms 1316 KB Output is correct
8 Correct 39 ms 1328 KB Output is correct
9 Correct 28 ms 1232 KB Output is correct
10 Correct 26 ms 1132 KB Output is correct
11 Correct 12 ms 560 KB Output is correct
12 Correct 28 ms 1120 KB Output is correct
13 Correct 29 ms 1204 KB Output is correct
14 Correct 21 ms 980 KB Output is correct
15 Correct 34 ms 1568 KB Output is correct
16 Correct 26 ms 1228 KB Output is correct
17 Correct 13 ms 708 KB Output is correct