제출 #1358323

#제출 시각아이디문제언어결과실행 시간메모리
1358323ivazivaRed-blue table (IZhO19_stones)C++20
43 / 100
14 ms1400 KiB
#include <bits/stdc++.h>

using namespace std;

#define MAXN 1001

int t,n,m;
char a[MAXN][MAXN];

int main()
{
    cin>>t;
    for (int test=0;test<t;test++)
    {
        cin>>n>>m;
        if (min(n,m)==n and n==5)
        {
            for (int row=1;row<=n;row++)
            {
                for (int col=1;col<=m;col++) a[row][col]='+';
            }
            for (int col=1;col<=m;col++) a[1][col]=a[2][col]='-';
            int curr=3;
            for (int col=1;col<=m;col++)
            {
                a[curr][col]='-';curr++;
                if (curr==6) curr=3;
            }
            cout<<n+m-2<<endl;
            for (int row=1;row<=n;row++)
            {
                for (int col=1;col<=m;col++) cout<<a[row][col];
                cout<<endl;
            }
        }
        else if (min(n,m)==m and m==5)
        {
            for (int row=1;row<=n;row++)
            {
                for (int col=1;col<=m;col++) a[row][col]='-';
            }
            for (int row=1;row<=n;row++) a[row][1]=a[row][2]='+';
            int curr=3;
            for (int row=1;row<=n;row++)
            {
                a[row][curr]='+';curr++;
                if (curr==6) curr=3;
            }
            cout<<n+m-2<<endl;
            for (int row=1;row<=n;row++)
            {
                for (int col=1;col<=m;col++) cout<<a[row][col];
                cout<<endl;
            }
        }
        else
        {
            if (n<=m)
            {
                int targeta=(n+1)/2-1,numa=m/2+1;
                for (int row=1;row<=targeta;row++)
                {
                    for (int col=1;col<=m;col++)
                    {
                        if (col<=numa) a[row][col]='+';
                        else a[row][col]='-';
                    }
                }
                for (int row=targeta+1;row<=n;row++)
                {
                    for (int col=1;col<=m;col++) a[row][col]='-';
                }
            }
            else
            {
                int targetb=(m+1)/2-1,numb=n/2+1;
                for (int col=1;col<=targetb;col++)
                {
                    for (int row=1;row<=n;row++)
                    {
                        if (row<=numb) a[row][col]='-';
                        else a[row][col]='+';
                    }
                }
                for (int col=targetb+1;col<=m;col++)
                {
                    for (int row=1;row<=n;row++) a[row][col]='+';
                }
            }
            cout<<max(n,m)+(min(n,m)+1)/2-1<<endl;
            for (int row=1;row<=n;row++)
            {
                for (int col=1;col<=m;col++) cout<<a[row][col];
                cout<<endl;
            }
        }
    }
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…