結果

問題 No.2247 01 ZigZag
ユーザー 👑 colognecologne
提出日時 2023-03-21 13:50:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 81,552 KB
実行使用メモリ 89,028 KB
最終ジャッジ日時 2023-10-18 20:19:17
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,424 KB
testcase_01 AC 37 ms
53,424 KB
testcase_02 AC 37 ms
53,424 KB
testcase_03 AC 61 ms
75,760 KB
testcase_04 AC 36 ms
53,440 KB
testcase_05 AC 60 ms
75,076 KB
testcase_06 AC 58 ms
70,900 KB
testcase_07 AC 35 ms
53,440 KB
testcase_08 AC 61 ms
80,600 KB
testcase_09 AC 62 ms
75,856 KB
testcase_10 AC 37 ms
53,440 KB
testcase_11 AC 56 ms
72,412 KB
testcase_12 AC 60 ms
75,116 KB
testcase_13 AC 58 ms
70,488 KB
testcase_14 AC 37 ms
53,440 KB
testcase_15 AC 60 ms
73,736 KB
testcase_16 AC 66 ms
80,632 KB
testcase_17 AC 68 ms
82,124 KB
testcase_18 AC 36 ms
53,440 KB
testcase_19 AC 37 ms
53,440 KB
testcase_20 AC 37 ms
53,440 KB
testcase_21 AC 52 ms
67,192 KB
testcase_22 AC 65 ms
82,276 KB
testcase_23 AC 54 ms
70,836 KB
testcase_24 AC 37 ms
53,440 KB
testcase_25 AC 64 ms
80,652 KB
testcase_26 AC 63 ms
76,656 KB
testcase_27 AC 66 ms
78,652 KB
testcase_28 AC 63 ms
82,232 KB
testcase_29 AC 62 ms
76,652 KB
testcase_30 AC 68 ms
84,388 KB
testcase_31 AC 37 ms
53,440 KB
testcase_32 AC 59 ms
81,612 KB
testcase_33 AC 54 ms
72,904 KB
testcase_34 AC 53 ms
73,568 KB
testcase_35 AC 52 ms
71,676 KB
testcase_36 AC 53 ms
72,880 KB
testcase_37 AC 47 ms
64,336 KB
testcase_38 AC 47 ms
64,392 KB
testcase_39 AC 49 ms
67,896 KB
testcase_40 AC 37 ms
53,440 KB
testcase_41 AC 51 ms
70,308 KB
testcase_42 AC 50 ms
70,248 KB
testcase_43 AC 36 ms
53,440 KB
testcase_44 AC 38 ms
53,440 KB
testcase_45 AC 74 ms
89,004 KB
testcase_46 AC 72 ms
89,028 KB
testcase_47 AC 36 ms
53,440 KB
testcase_48 AC 37 ms
53,440 KB
testcase_49 AC 36 ms
53,440 KB
testcase_50 AC 37 ms
53,440 KB
testcase_51 AC 36 ms
53,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)


def ok(N, M, K):
    mn = 1 if M > 0 else 0
    mx = min(2*M, 2*N+1)
    return mn <= K <= mx


def s(N, M, K, L):
    if L == 0 and not ok(N, M, K):
        return None
    if L == 1 and not ok(M, N, K):
        return None
    arr = [L]
    for i in range(N+M):
        if N > 0 and ok(N-1, M, K - (L != 0)):
            arr.append(0)
            N -= 1
            K -= L != 0
            L = 0
        else:
            arr.append(1)
            M -= 1
            K -= L != 1
            L = 1
    return ''.join(map(str, arr))


def main():
    N, M, K = map(int, input().split())
    A = None
    if N > 0:
        A = s(N-1, M, K, 0)
    if M > 0 and A is None:
        A = s(N, M-1, K, 1)
    if A is None:
        print(-1)
    else:
        print(A)


if __name__ == '__main__':
    main()
0