Submission #992847

# Submission time Handle Problem Language Result Execution time Memory
992847 2024-06-05T07:50:37 Z NValchanov Red-blue table (IZhO19_stones) C++17
15 / 100
31 ms 2396 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++)
            {
                table[i][j] ^= 1;

                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 1368 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 7 ms 1368 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 1368 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 31 ms 2388 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 20 ms 2396 KB Output is correct
2 Correct 14 ms 2140 KB Output is correct
3 Correct 13 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1368 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -