Submission #494853

# Submission time Handle Problem Language Result Execution time Memory
494853 2021-12-16T20:41:07 Z Amer Red-blue table (IZhO19_stones) C++14
0 / 100
48 ms 1460 KB
#include <iostream>

using namespace std;

const int maxN = 8;

bool marked[maxN][maxN];

int num[maxN];

int solve(int n, int m)
{
    int midN = n / 2 + 1;
    int midM = m / 2 + m % 2 - 1;

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

    int sum = n;

    int pointer = 1;

    for (int i = 1; i <= m; i++)
    {
        int steps;

        bool full = false;

        for (steps = 1; steps <= midN; steps++)
        {
            if (num[pointer] >= midM)
            {
                full = true;
                break;
            }

            marked[i][pointer] = true;
            num[pointer]++;

            pointer++;

            if (pointer > n)
            {
                pointer = 1;
            }
        }

        if (steps >= midN + 1)
        {
            sum++;
        }

        if(full)
        {
            break;
        }
    }

    cout << sum << endl;

    return 0;
}

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

    if (n > m)
    {
        sum = solve(n, m);

        int place = 0;

        for (int i = 1; i <= n; i++)
        {
            for (int j = m; j >= 1; j--)
            {
                if (marked[i][j])
                {
                    cout << "+";
                }
                else
                {
                    cout << "-";
                }
            }

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

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (marked[i][j])
                {
                    cout << "+";
                }
                else
                {
                    cout << "-";
                }
            }

            cout << endl;
        }
    }

    cout << sum << 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;
}

///5 6

Compilation message

stones.cpp: In function 'void test(int, int)':
stones.cpp:78:13: warning: unused variable 'place' [-Wunused-variable]
   78 |         int place = 0;
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer
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 204 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 1460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 1368 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer
2 Halted 0 ms 0 KB -