제출 #992869

#제출 시각아이디문제언어결과실행 시간메모리
992869NValchanovRed-blue table (IZhO19_stones)C++17
100 / 100
17 ms2288 KiB
#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const int MAXN = 1e3 + 10;

int n, m;
bool table[MAXN][MAXN];
int ans;
bool sw;

void read()
{
    sw = false;
    cin >> n >> m;
    if(n < m)
    {
        swap(n, m);
        sw = true;
    }
}

void solve()
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            table[i][j] = true;
        }
    }
    ans = n;
    int j = 1;
    int placed = 0;
    for(int k = 1; k <= (m - 1) / 2; k++)
    {
        for(int i = 1; i <= n; i++)
        {
            table[i][j] = false;
            
            if(++placed == n / 2 + 1)
            {
                ans++;
                placed = 0;
                j++;
            }
        }
    }
}

void print()
{
    if(!sw)
    {
        cout << ans << endl;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                cout << (table[i][j] ? '+' : '-');
            }
            cout << endl;
        }
    }
    else
    {
        cout << ans << endl;
        for(int j = 1; j <= m; j++)
        {
            for(int i = 1; i <= n; i++)
            {
                cout << (!table[i][j] ? '+' : '-');
            }
            
            cout << endl;
        }
    }
}

int main()
{
    // #ifdef ONLINE_JUDGE
    //     freopen(".in", "r", stdin);
    //     freopen(".out", "w", stdout);
    // #endif

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    while(t--)
    {
        read();
        solve();
        print();
    }

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