結果
| 問題 | No.2247 01 ZigZag | 
| コンテスト | |
| ユーザー |  kcvlex | 
| 提出日時 | 2023-03-17 21:44:48 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 1,005 bytes | 
| コンパイル時間 | 2,621 ms | 
| コンパイル使用メモリ | 150,028 KB | 
| 最終ジャッジ日時 | 2025-02-11 12:49:28 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 50 | 
ソースコード
#include <iostream>
#include <atcoder/all>
#define ALL(V) std::begin(V), std::end(V)
std::string solve(int N, int M, int K) {
    if (N == 0 || M == 0) {
        if (K == 0) {
            char c = '0' + (N == 0);
            return std::string(N + M, c);
        } else {
            return "-1";
        }
    }
    if (K == 0) return "-1";
    int max = std::min(N, M) * 2 - (N == M);
    if (max < K) return "-1";
    if (K == max && N < M) {
        std::string s;
        for (int i = 0; i < N; i++) s += "10";
        s += std::string(M - N, '1');
        return s;
    }
    std::string ans = "01";
    N--; M--; K--;
    while (2 <= K) {
        assert(N && M);
        ans += "01";
        K -= 2;
        N--; M--;
    }
    ans += std::string(M, '1');
    if (K == 1) {
        assert(N);
        ans += '0';
        N--;
    }
    return std::string(N, '0') + ans;
}
int main() {
    int N, M, K;
    std::cin >> N >> M >> K;
    std::cout << solve(N, M, K) << std::endl;
    return 0;
}
            
            
            
        