結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, M, K; cin >> N >> M >> K;
    if (K == 0) {
        if (N != 0 && M != 0) cout << -1 << "\n";
        cout << string(N, '0') + string(M, '1') << "\n";
        return 0;
    }
    int x = (K + 2) / 2, y = (K + 1) / 2;
    string s, t;
    vector<int> v(K + 1, 1), w(K + 1, 1);
    if (x <= N && y <= M) {
        int n = x, m = y;
        v[0] += N - n;
        if (K & 1) v[K] += M - m;
        else v[K - 1] += M - m;
        for (int i = 0; i < v.size(); i++) {
            if (i & 1) s += string(v[i], '1');
            else s += string(v[i], '0');
        }
    }
    if (x <= M && y <= N) {
        int n = y, m = x;
        w[1] += N - n;
        if (K & 1) w[K - 1] += M - m;
        else w[K] += M - m;
        for (int i = 0; i < w.size(); i++) {
            if (i & 1) t += string(w[i], '0');
            else t += string(w[i], '1');
        }
    }
    if (s == "" && t == "") cout << -1 << "\n";
    else if (s == "") cout << t << "\n";
    else if (t == "") cout << s << "\n";
    else cout << min(s, t) << "\n";
    return 0;
}
0