Submission #499244

# Submission time Handle Problem Language Result Execution time Memory
499244 2021-12-27T13:58:03 Z RedBoy Red-blue table (IZhO19_stones) C++11
0 / 100
34 ms 3268 KB
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1005;

int T;
int cont[N];
bool marked[N][N];

int solve(int n, int m)
{
    int maxN = (n - 1) / 2, minM = m / 2 + 1, index = 1, rowCont = 0;

    for(int i = 1; i <= n; i++)
    {
        int j;
        for(j = 1; j <= minM; j++)
        {
            while(cont[index] >= maxN && index <= m)
                index++;
            if(index > m)
                break;

            cont[index]++;
            marked[i][index] = 1;

            if(index == m)
                index = 1;
            else
                index++;
        }

        if(j == minM + 1)
            rowCont++;
    }

    /*
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
            cout << marked[i][j] << ' ';
        cout << '\n';
    }
    */

    return m + rowCont;
}

void print(int n, int m, int val, bool inverted)
{
    cout << val << '\n';
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(!inverted)
                cout << (marked[i][j] ? "+ " : "- ");
            else
                cout << (marked[j][i] ? "- " : "+ ");
        }
        cout << '\n';
    }
}

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

    cin >> T;
    while(T--)
    {
        memset(marked, 0, sizeof marked);
        memset(cont, 0, sizeof cont);
        int n, m;
        cin >> n >> m;

        if(n <= m)
            print(n, m, solve(n, m), 0);
        else
            print(n, m, solve(m, n), 1);
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1224 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1228 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1224 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 3200 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3268 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1224 KB Wrong answer
2 Halted 0 ms 0 KB -