Submission #1347619

#TimeUsernameProblemLanguageResultExecution timeMemory
1347619SSKMFRed-blue table (IZhO19_stones)C++20
53 / 100
5 ms1348 KiB
#include <bits/stdc++.h>
using namespace std;

void Solve ()
{
    int linii , coloane;
    cin >> linii >> coloane;

    pair <int , int> maxim = {-1 , -1};
    for (int termen_1 = 0 ; termen_1 <= linii ; termen_1++)
    {
        const int limita_1 = (coloane - 1) / 2;
        const int necesar = (linii + 2) / 2 - (linii - termen_1);
        int termen_2 = 0;

        if (necesar <= 0) { termen_2 = coloane; }
        else { termen_2 = min(coloane , termen_1 / necesar * limita_1); }

        maxim = max(maxim , {termen_1 + termen_2 , termen_1});
    }

    cout << maxim.first << '\n';

    const int limita_1 = (coloane - 1) / 2;
    const int necesar = (linii + 2) / 2 - (linii - maxim.second);
    for (int linie = 1 ; linie <= linii ; linie++) {
        if (linie > maxim.second) {
            for (int coloana = 1 ; coloana <= coloane ; coloana++)
                { cout.put('-'); }
            cout.put('\n');
        } else {
            const int stanga = (necesar == 0 ? coloane + 1 : 1 + (linie - 1) / necesar * limita_1);
            const int dreapta = min(coloane , stanga + limita_1 - 1);
            for (int coloana = 1 ; coloana <= coloane ; coloana++) {
                if (stanga <= coloana && coloana <= dreapta) { cout.put('-'); }
                else { cout.put('+'); }
            }
            cout.put('\n');
        }
    }
}

int main ()
{
    ios :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int numar_teste;
    cin >> numar_teste;
    while (numar_teste--)
        { Solve(); }

    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...