Submission #494856

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

using namespace std;

const int maxN = 1005;

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(m, n);

        int place = 0;

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; 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 = m; j >= 1; j--)
            {
                if (marked[i][j])
                {
                    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;
}

///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;
      |             ^~~~~
stones.cpp:72:9: warning: variable 'sum' set but not used [-Wunused-but-set-variable]
   72 |     int sum = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 332 KB in the table A+B is not equal to 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 1408 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1428 KB in the table A+B is not equal to 20
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 332 KB Wrong answer in test 2 1: 1 < 2