結果

問題 No.2247 01 ZigZag
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-09 12:24:21
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,375 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 202,380 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 17:12:56
合計ジャッジ時間 4,878 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, m, k;
    cin >> n >> m >> k;
    if (k % 2 == 1) {
        if (n < (k + 1) / 2 || m < (k + 1) / 2) {
            cout << "-1\n";
            return 0;
        }
        vector<int> cnt(k + 1, 1);
        cnt[0] += n - (k + 1) / 2;
        cnt.back() += m - (k + 1) / 2;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j < cnt[i]; j++) {
                cout << i % 2;
            }
        }
        cout << endl;
        return 0;
    }
    if (n < (k + 1) / 2 || m < (k + 1) / 2) {
        cout << "-1\n";
        return 0;
    }
    if (n < (k + 2) / 2) {
        if (m < (k + 2) / 2) {
            cout << "-1\n";
            return 0;
        }
        vector<int> cnt(k + 1, 1);
        cnt[1] += n - (k + 1) / 2;
        cnt.back() += m - (k + 2) / 2;
        for (int i = 0; i <= k; i++) {
            for (int j = 0; j < cnt[i]; j++) {
                cout << (i + 1) % 2;
            }
        }
        cout << endl;
        return 0;
    }
    vector<int> cnt(k + 1, 1);
    cnt[0] += n - (k + 2) / 2;
    cnt[k - 1] += m - (k + 1) / 2;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j < cnt[i]; j++) {
            cout << i % 2;
        }
    }
    cout << endl;
}
0