답안 #992869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992869 2024-06-05T07:58:39 Z NValchanov Red-blue table (IZhO19_stones) C++17
100 / 100
17 ms 2288 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()
{
    sw = false;
    cin >> n >> m;
    if(n < m)
    {
        swap(n, m);
        sw = true;
    }
}

void solve()
{
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            table[i][j] = true;
        }
    }
    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] = false;
            
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1372 KB Output is correct
2 Correct 15 ms 2140 KB Output is correct
3 Correct 14 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 1368 KB Output is correct
2 Correct 15 ms 1884 KB Output is correct
3 Correct 12 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 17 ms 1372 KB Output is correct
6 Correct 15 ms 2140 KB Output is correct
7 Correct 14 ms 2140 KB Output is correct
8 Correct 16 ms 1368 KB Output is correct
9 Correct 15 ms 1884 KB Output is correct
10 Correct 12 ms 1628 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 12 ms 1896 KB Output is correct
13 Correct 15 ms 2140 KB Output is correct
14 Correct 11 ms 1628 KB Output is correct
15 Correct 17 ms 2288 KB Output is correct
16 Correct 14 ms 1880 KB Output is correct
17 Correct 6 ms 1372 KB Output is correct