Submission #494617

# Submission time Handle Problem Language Result Execution time Memory
494617 2021-12-15T20:36:07 Z Amer Red-blue table (IZhO19_stones) C++14
0 / 100
9 ms 464 KB
#include <iostream>

using namespace std;

const int maxN = 8;

int marked[maxN][maxN];

int c[maxN];

int solve(int n, int m)
{
    ///N > M

    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            marked[i][j] = 0;
        }
    }

    int centerN = n / 2;
    int centerM = m / 2 - 1;

    for(int col = 0;col <= centerM; col++)
    {
        for(int row = col * centerN + col; row <= (col + 1) * centerN; row++)
        {
            if(row >= n)
            {
                break;
            }

            marked[row][col] = 1;
        }
    }

    int sum = n;

    for(int j = 0;j < m;j++)
    {
        int num = 0;

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

            if(marked[i][j] == 1)
            {
                num++;
            }
            else
            {
                break;
            }

            //cout<<marked[i][j]<<" ";
        }

        //cout<<num<<endl;
        //cout<<centerN + 1<<endl;

        if(num >= centerN + 1)
        {
            sum++;
        }

        //cout<<endl;
    }

    /*
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            cout<<marked[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    return sum;

}

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

    if(n < m)
    {
        //swap(n, m);

        sum = solve(m, n);
    }
    else
    {
        sum = solve(n, m);
    }

    cout<<sum<<endl;

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

        int total = 0;

        for(int row = 0;row < m;row++)
        {
            for(int col = 0;col < n;col++)
            {
                total++;
                //cout<<row<<" "<<col<<endl;
                if(marked[row][col] == 1)
                {
                    cout<<"+";
                }
                else
                {
                    cout<<"-";
                }

                if(total % m == 0)
                {
                    cout<<endl;
                }
            }
        }
    }
}

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

    int t;
    cin>>t;

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

        cin>>n>>m;
        test(n,m);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 464 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 5