답안 #893272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893272 2023-12-26T19:36:41 Z maxFedorchuk Red-blue table (IZhO19_stones) C++14
100 / 100
21 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;

void fun()
{
    long long n,m;
    cin>>n>>m;

    bool swp=0;

    if(m>n)
    {
        swap(n,m);
        swp=1;
    }

    char ch[n+5][m+5];

    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;j<=m;j++)
        {
            ch[i][j]='+';
        }
    }

    long long mx_can_in_row=(m-1)/2;
    long long mn_ned_st=n/2+1;

    long long zarc=0,st=1,ans=n;

    for(long long i=0;i<mx_can_in_row;i++)
    {
        for(long long j=1;(j<=n && st<=m);j++)
        {
            ch[j][st]='-';

            zarc++;

            if(zarc>=mn_ned_st)
            {
                st++;
                zarc=0;
                ans++;
            }
        }
    }

    cout<<ans<<"\n";

    if(swp)
    {
        for(long long j=1;j<=m;j++)
        {
            for(long long i=1;i<=n;i++)
            {
                if(ch[i][j]=='+')
                {
                    cout<<"-";
                }
                else
                {
                    cout<<"+";
                }
            }

            cout<<"\n";
        }
    }
    else
    {
        for(long long i=1;i<=n;i++)
        {
            for(long long j=1;j<=m;j++)
            {
                cout<<ch[i][j];
            }
            cout<<"\n";
        }
    }

    return;
}

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

    long long t;
    cin>>t;

    while(t--)
    {
        fun();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1368 KB Output is correct
2 Correct 15 ms 1884 KB Output is correct
3 Correct 14 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1376 KB Output is correct
2 Correct 14 ms 1624 KB Output is correct
3 Correct 14 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 17 ms 1368 KB Output is correct
6 Correct 15 ms 1884 KB Output is correct
7 Correct 14 ms 1880 KB Output is correct
8 Correct 21 ms 1376 KB Output is correct
9 Correct 14 ms 1624 KB Output is correct
10 Correct 14 ms 1368 KB Output is correct
11 Correct 5 ms 668 KB Output is correct
12 Correct 17 ms 1544 KB Output is correct
13 Correct 14 ms 1368 KB Output is correct
14 Correct 10 ms 1116 KB Output is correct
15 Correct 17 ms 2396 KB Output is correct
16 Correct 13 ms 1860 KB Output is correct
17 Correct 6 ms 848 KB Output is correct