답안 #500596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500596 2021-12-31T13:52:40 Z kusmetliq Red-blue table (IZhO19_stones) C++14
0 / 100
58 ms 1296 KB
#include<bits/stdc++.h>
using namespace std;
vector<char>anss[1002];
void sollve(int n,int m)
{
    {
        for(int i=0;i<n;i++)
        {
            if(i<n/2)
            {
                for(int j=0;j<m/2+1;j++)anss[i].push_back('+');
                for(int j=m/2+1;j<m;j++)anss[i].push_back('-');
            }
            else if(i==n/2)
            {
                for(int j=0;j<m;j++)anss[i].push_back('-');
            }
            else
            {
                for(int j=m/2+1;j<m;j++)anss[i].push_back('-');
                for(int j=0;j<m/2+1;j++)anss[i].push_back('+');
            }
        }
    }
}
void solve()
{
    int n,m;
    cin>>n>>m;
    if(n%2==1 && m%2==1)
    {
        sollve(n,m);
        cout<<m-1+n-1<<endl;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)cout<<anss[i][j];
                cout<<endl;
                anss[i].clear();
            }
        return;
    }
    char ans1[n][m],ans2[n][m];
    int a1=n,a2=m;
    vector<int>v1(n,0),v2(m,0);
    for(int j=0;j<m;j++)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(v1[i]<(m+1)/2-1)cnt++;
        }
        if(cnt>n/2)
        {
            a1++;
            int num=n/2+1;
            for(int i=0;i<n;i++)
            {
                if(v1[i]<m/2 && num!=0)
                {
                    v1[i]++;
                    num--;
                    ans1[i][j]='-';
                }
                else ans1[i][j]='+';
            }
        }
        else for(int i=0;i<n;i++)ans1[i][j]='+';
    }
    for(int i=0;i<n;i++)
    {
        int cnt=0;
        for(int j=0;j<m;j++)
        {
            if(v2[j]<(n+1)/2-1)cnt++;
        }
        if(cnt>m/2)
        {
            a2++;
            int num=m/2+1;
            for(int j=0;j<m;j++)
            {
                if(v2[j]<n/2 && num!=0)
                {
                    v2[j]++;
                    num--;
                    ans2[i][j]='+';
                }
                else ans2[i][j]='-';
            }
        }
        else for(int j=0;j<m;j++)ans2[i][j]='-';
    }
    cout<<max(a1,a2)<<endl;
    if(a2>a1)
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
                cout<<ans2[i][j];
            cout<<endl;
        }
    else
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
                cout<<ans1[i][j];
            cout<<endl;
        }
}
int main()
{
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 316 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 332 KB in the table A+B is not equal to 10
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 316 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 1240 KB in the table A+B is not equal to 76
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 1296 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 316 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -