結果

問題 No.2247 01 ZigZag
ユーザー SSRSSSRS
提出日時 2023-03-17 21:28:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 168,432 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 16:05:40
合計ジャッジ時間 2,613 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  if (K > N + M - 1 || K > N * 2 || K > M * 2){
    cout << -1 << endl;
  } else if (N == 0){
    if (K > 0){
      cout << -1 << endl;
    } else {
      cout << string(M, '1') << endl;
    }
  } else if (M == 0){
    if (K > 0){
      cout << -1 << endl;
    } else {
      cout << string(N, '0') << endl;
    }
  } else if (K == 0){
    cout << -1 << endl;
  } else if (K == N * 2){
    string S;
    for (int i = 0; i < N; i++){
      S += "10";
    }
    for (int i = 0; i < M - N; i++){
      S += '1';
    }
    cout << S << endl;
  } else if (K % 2 == 1){
    string S;
    for (int i = 0; i < N - K / 2; i++){
      S += '0';
    }
    for (int i = 0; i < K / 2; i++){
      S += "10";
    }
    for (int i = 0; i < M - K / 2; i++){
      S += '1';
    }
    cout << S << endl;
  } else {
    string S;
    for (int i = 0; i < N - K / 2; i++){
      S += '0';
    }
    for (int i = 0; i < K / 2 - 1; i++){
      S += "10";
    }
    for (int i = 0; i < M - (K / 2 - 1); i++){
      S += '1';
    }
    S += '0';
    cout << S << endl;
  }
}
0