結果

問題 No.2247 01 ZigZag
ユーザー tnakao0123tnakao0123
提出日時 2023-05-18 14:42:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 64,116 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-08-22 09:42:28
合計ジャッジ時間 2,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

/* constant */

/* typedef */

typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

/* global variables */

/* subroutines */

string ps2s(vpii &ps) {
  string s;
  for (auto &p: ps) {
    int ch = '0' + p.first;
    for (int j = 0; j < p.second; j++) s += ch;
  }
  return s;
}

string calc(int d0, int d1, int n0, int n1, int k) {
  int ds[2] = { d0, d1 }, ns[2] = { n0, n1 };
  vpii ps;
  for (int i = 0; i <= k; i++) {
    int p = i & 1;
    ps.push_back({ds[p], 1});
    ns[p]--;
  }
  if (ns[0] < 0 || ns[1] < 0) return "2";

  int i0 = 0, i1 = ps.size() - 1;
  if (ps[i0].first != 0) i0++;
  if (ps[i1].first != 1) i1--;
  ps[i0].second += ns[0];
  ps[i1].second += ns[1];

  return ps2s(ps);
}

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  if (k == 0) {
    if (n > 0 && m > 0) { puts("-1"); return 0; }
    vpii ps({{0, n}, {1, m}});
    string s = ps2s(ps);
    puts(s.c_str());
    return 0;
  }

  string s0 = calc(0, 1, n, m, k);
  string s1 = calc(1, 0, m, n, k);
  string s = min(s0, s1);

  if (s[0] >= '2') puts("-1");
  else puts(s.c_str());
  return 0;
}
0