Submission #494859

# Submission time Handle Problem Language Result Execution time Memory
494859 2021-12-16T20:54:13 Z Amer Red-blue table (IZhO19_stones) C++14
0 / 100
48 ms 1396 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 - 1) / 2;

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

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 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 332 KB in the table A+B is not equal to 8
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 1392 KB in the table A+B is not equal to 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 1396 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 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 3