Submission #746556

# Submission time Handle Problem Language Result Execution time Memory
746556 2023-05-22T18:29:35 Z Denkata Red-blue table (IZhO19_stones) C++14
0 / 100
28 ms 1400 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int i,j,p,q,n,m,k;
int T;
char  ans[1006][1006];
int  do_count()
{
    int otg = 0;
    for(i=1;i<=n;i++)
    {
        int br = 0;
        for(j=1;j<=m;j++)
        {
           // cout<<ans[i][j]<<" "<<br<<endl;
            if(ans[i][j]=='+')
                br++;
        }
       // cout<<i<<" "<<br<<endl;
        if(br>=m/2+1)otg++;
    }
    for(i=1;i<=m;i++)
    {
        int br = 0;
        for(j=1;j<=n;j++)
        {
            if(ans[j][i]=='-')
                br++;

        }
        if(br>=n/2+1)otg++;
    }
    return otg;
}
void solve()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            ans[i][j] = '&';
        }
    }

    if(n==1)
    {
        cout<<m<<endl;
        for(j=1;j<=m;j++)
            cout<<'-';
        cout<<endl;
        return ;
    }
    if(m==1)
    {
        cout<<n<<endl;
        for(j=1;j<=n;j++)
            cout<<'-'<<endl;
        return ;
    }
    if(n==2 || m==2)
    {
        char znak = '+';
        if(m>n)znak = '-';
        for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
                ans[i][j]=znak;
        cout<<do_count()<<endl;
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=m;j++)
                cout<<ans[i][j];
            cout<<endl;
        }
        return ;
    }
    if(n%2==0 && m%2==0)
    {

    }
    int non_dom = n/2;
    int non_domm = m/2;
    if(m%2==0)
        non_domm--;
    if(n%2==0)
        non_dom--;
    for(i=1;i<=non_dom;i++)
    {
        for(j=1;j<=m/2+1;j++)
            ans[i][j]='+';
    }
    for(i=non_dom+1;i<=n;i++)
    {
        for(j=1;j<=non_domm;j++)
            ans[i][j]='-';
    }
    for(i=1;i<=n/2+1;i++)
    {
        for(j=m/2+2;j<=m;j++)
            ans[i][j]='-';
    }

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(ans[i][j]=='&')
                ans[i][j]='+';

        }
    }
    if(n==4 && m==4)
        ans[2][4]=ans[3][4]='+';
    cout<<do_count()<<endl;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
            cout<<ans[i][j];
        cout<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>T;
    while(T--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1352 KB in the table A+B is not equal to 87
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1400 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -