結果

問題 No.2247 01 ZigZag
ユーザー tnakao0123tnakao0123
提出日時 2023-05-18 13:42:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 42,204 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-22 09:12:50
合計ジャッジ時間 3,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
  }

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