제출 #494202

#제출 시각아이디문제언어결과실행 시간메모리
494202AmerRed-blue table (IZhO19_stones)C++14
27 / 100
42 ms1268 KiB
#include <iostream>

using namespace std;

void fastscan(int &x)
    {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

void test(int n, int m)
{
    int sum = 0;

    if(n >= m)
    {
        sum = n + m / 2 + m % 2 - 1;
    }
    else
    {
        sum = m + n / 2 + n % 2 - 1;
    }

    cout<<sum<<endl;

    for(int row = 0;row < n;row++)
    {
        for(int col = 0;col < m;col++)
        {
            if(n >= m)
            {
                if(col < m / 2 + m % 2 - 1)
                {
                    cout<<"-";
                }
                else
                {
                    cout<<"+";
                }
            }
            else
            {
                if(row < n / 2 + n % 2 - 1)
                {
                    cout<<"+";
                }
                else
                {
                    cout<<"-";
                }
            }
        }
        cout<<endl;
    }
}

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

    int t;

    fastscan(t);

    for(int i = 0;i < t;i++)
    {
        int n,m;

        fastscan(n);
        fastscan(m);

        //cin>>n>>m;
        test(n,m);
    }
    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...