Submission #992853

# Submission time Handle Problem Language Result Execution time Memory
992853 2024-06-05T07:52:48 Z NValchanov Red-blue table (IZhO19_stones) C++17
15 / 100
44 ms 2384 KB
#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const int MAXN = 1e3 + 10;

int n, m;
bool table[MAXN][MAXN];
int ans;
bool sw;

void read()
{
    cin >> n >> m;
    if(n < m)
    {
        swap(n, m);
        sw = true;
    }
}

void solve()
{
    memset(table, 1, sizeof(table));
    ans = n;
    int j = 1;
    int placed = 0;
    for(int k = 1; k <= (m - 1) / 2; k++)
    {
        for(int i = 1; i <= n; i++)
        {
            table[i][j] = 0;
            
            if(++placed == n / 2 + 1)
            {
                ans++;
                placed = 0;
                j++;
            }
        }
    }
}

void print()
{
    if(!sw)
    {
        cout << ans << endl;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            {
                cout << (table[i][j] ? '+' : '-');
            }
            cout << endl;
        }
    }
    else
    {
        cout << ans << endl;
        for(int j = 1; j <= m; j++)
        {
            for(int i = 1; i <= n; i++)
            {
                cout << (!table[i][j] ? '-' : '+');
            }
            
            cout << endl;
        }
    }
}

int main()
{
    // #ifdef ONLINE_JUDGE
    //     freopen(".in", "r", stdin);
    //     freopen(".out", "w", stdout);
    // #endif

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    while(t--)
    {
        read();
        solve();
        print();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1372 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1372 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1372 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 2304 KB in the table A+B is not equal to 78
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2384 KB Output is correct
2 Correct 20 ms 2124 KB Output is correct
3 Correct 13 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1372 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -