結果

問題 No.2247 01 ZigZag
ユーザー jianglyjiangly
提出日時 2023-03-21 23:45:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 193,956 KB
最終ジャッジ日時 2025-02-11 15:57:42
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N, M, K;
    std::cin >> N >> M >> K;
    
    if (K < 0 || K > std::min({2 * N, 2 * M, N + M - 1})) {
        std::cout << -1 << "\n";
        return 0;
    }
    
    int t = N > M ? 0 : 1;
    int cnt[2] = {N, M};
    for (int i = 0; i < N + M; i++) {
        if (K == 1) {
            if (!cnt[t]) {
                t ^= 1;
                K = 0;
            }
        } else if (i > 0 && K > 1) {
            t ^= 1;
            K -= 1;
        }
        std::cout << t;
        cnt[t] -= 1;
    }
    std::cout << "\n";
    
    return 0;
}
0