제출 #681546

#제출 시각아이디문제언어결과실행 시간메모리
681546Matteo_VerzRed-blue table (IZhO19_stones)C++17
27 / 100
33 ms1236 KiB
#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;
}
#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...