Submission #494593

# Submission time Handle Problem Language Result Execution time Memory
494593 2021-12-15T19:26:36 Z Amer Red-blue table (IZhO19_stones) C++14
0 / 100
7 ms 460 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;
    }

    return sum;

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

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

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

    cout<<sum<<endl;

    for(int row = 0;row < n;row++)
    {
        for(int col = 0;col < m;col++)
        {
            if(marked[row][col] == 1)
            {
                cout<<"-";
            }
            else
            {
                cout<<"+";
            }
        }
        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 Incorrect 0 ms 316 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 460 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB in the table A+B is not equal to 3
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 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -