結果

問題 No.2247 01 ZigZag
ユーザー magurofly
提出日時 2023-03-17 21:49:17
言語 Ruby
(3.4.1)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-09-18 16:07:17
合計ジャッジ時間 6,085 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N, M, K = gets.split.map(&:to_i)

min_sep, max_sep = [N, M].minmax
sep = min_sep + [min_sep + 1, max_sep].min

C = K + 1

if sep < C
    puts -1
    exit
end

if C == 1
    if N > 0 and M > 0
        puts -1
    elsif N > 0
        puts "0" * N
    else
        puts "1" * M
    end
    exit
end

if C.even?
    puts "0" * (N - (C / 2 - 1)) + "10" * (C / 2 - 1) + "1" * (M - (C / 2 - 1))
elsif N == C / 2
    puts "10" * (C / 2) + "1" * (M - C / 2)
else
    puts "0" * (N - C / 2) + "10" * (C / 2 - 1) + "1" * (M - (C / 2 - 1)) + "0"
end
0