답안 #502593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502593 2022-01-06T10:12:22 Z tim Red-blue table (IZhO19_stones) C++14
100 / 100
31 ms 5152 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define y1 tim
#define endl "\n"

#define sz(x) (long long)(x).size()
#define all(x) (x).begin(), (x).end()

using namespace std;

mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

int t, n, m, answer, ans[1010][1010], cnt[1010], fl, x;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> m;
        if (m > n)
        {
            answer = m;
            for (int i = 1; i <= n; i++) for (int o = 1; o <= m; o++) ans[i][o] = 0;
            for (int i = 0; i <= m; i++) cnt[i] = 0;
            fl = 0;
            x = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int o = 1; o <= m/2 + 1; o++)
                {
                    if (cnt[x] + 1 >= n/2 + n%2)
                    {
                        fl = 1;
                        break;
                    }
                    else
                    {
                        cnt[x]++;
                        ans[i][x + 1] = 1;
                        x++;
                    }
                    x %= m;
                }
                if (fl == 1) break;
                answer++;
            }
        }
        else
        {
            answer = n;
            for (int i = 1; i <= n; i++) for (int o = 1; o <= m; o++) ans[i][o] = 1;
            for (int i = 0; i <= n; i++) cnt[i] = 0;
            fl = 0;
            x = 0;
            for (int i = 1; i <= m; i++)
            {
                for (int o = 1; o <= n/2 + 1; o++)
                {
                    if (cnt[x] + 1 >= m/2 + m%2)
                    {
                        fl = 1;
                        break;
                    }
                    else
                    {
                        cnt[x]++;
                        ans[x + 1][i] = 0;
                        x++;
                    }
                    x %= n;
                }
                if (fl == 1) break;
                answer++;
            }
        }
        cout << answer << endl;
        for (int i = 1; i <= n; i++)
        {
            for (int o = 1; o <= m; o++)
            {
                if (ans[i][o] == 0) cout << "-";
                else cout << "+";
            }
            cout << endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1712 KB Output is correct
2 Correct 31 ms 4140 KB Output is correct
3 Correct 21 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1884 KB Output is correct
2 Correct 19 ms 3956 KB Output is correct
3 Correct 17 ms 3268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 31 ms 1712 KB Output is correct
6 Correct 31 ms 4140 KB Output is correct
7 Correct 21 ms 4856 KB Output is correct
8 Correct 27 ms 1884 KB Output is correct
9 Correct 19 ms 3956 KB Output is correct
10 Correct 17 ms 3268 KB Output is correct
11 Correct 6 ms 600 KB Output is correct
12 Correct 21 ms 4240 KB Output is correct
13 Correct 21 ms 4716 KB Output is correct
14 Correct 15 ms 3924 KB Output is correct
15 Correct 23 ms 5152 KB Output is correct
16 Correct 17 ms 4216 KB Output is correct
17 Correct 12 ms 3268 KB Output is correct