답안 #681546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681546 2023-01-13T09:46:00 Z Matteo_Verz Red-blue table (IZhO19_stones) C++17
27 / 100
33 ms 1236 KB
#include <bits/stdc++.h>

using namespace std;

auto solve(int x, int y) {
    char ch, replacech;
    if (x >= y) {
        ch = '+';
        replacech = '-';
    } else {
        ch = '-';
        replacech = '+';
    }

    vector <vector <char>> a(x, vector <char>(y, ch));
    int ans;
    if (x >= y) {
        ans = x;
        for (int j = 0; j < (y - 1) / 2; j++) {
            for (int i = 0; i < x / 2 + 1; i++)
                a[i][j] = replacech;
            ans++;
        }
    } else {
        ans = y;
        vector <int> freq(y);
        int pos = 0, line = 0;
        while (true) {
            if (freq[(pos + y / 2) % y] < (x - 1) / 2) {
                for (int i = pos; i <= pos + y / 2; i++) {
                    freq[i % y]++;
                    a[line][i % y] = replacech;
                }
                pos = (pos + y / 2 + 1) % y;
            } else break;
            line++;
            ans++;
        }
    }

    cout << ans << '\n';
    return a;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        int x, y;
        cin >> x >> y;
        auto a = solve(x, y);

        for (int i = 0; i < x; i++, cout << '\n')
            for (int j = 0; j < y; j++)
                cout << a[i][j];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 3 ms 340 KB Wrong answer in test 37 5: 39 < 40
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 1224 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 1236 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 3 ms 340 KB Wrong answer in test 37 5: 39 < 40
5 Halted 0 ms 0 KB -