結果

問題 No.2247 01 ZigZag
ユーザー tnakao0123tnakao0123
提出日時 2023-05-18 13:46:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 42,564 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 04:59:47
合計ジャッジ時間 2,228 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 16 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2247.cc:  No.2247 01 ZigZag - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;
const int MAX_L = MAX_N + MAX_M;

/* typedef */

/* global variables */

char s[MAX_L + 4];

/* subroutines */

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int l = n + m;
  int cs[2] = {n, m};

  if (k == 0) {
    if (n > 0 && m > 0) { puts("-1"); return 0; }
    for (int i = 0; i < n; i++) s[i] = '0';
    for (int i = 0; i < m; i++) s[i] = '1';
    puts(s);
    return 0;
  }

  int d0 = (n >= m) ? 0 : 1;
  if (k > min(cs[d0], cs[d0 ^ 1] + 1)) { puts("-1"); return 0; }

  int i = 0, d = d0;
  while (k > 1) {
    s[i++] = '0' + d;
    cs[d]--, k--;
    d ^= 1;
  }

  d ^= 1;
  while (cs[d]--) s[i++] = '0' + d;
  d ^= 1;
  while (cs[d]--) s[i++] = '0' + d;
  puts(s);
  return 0;
}
0