結果

問題 No.2247 01 ZigZag
ユーザー ShirotsumeShirotsume
提出日時 2023-03-08 14:19:46
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,546 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 80,112 KB
最終ジャッジ日時 2024-09-18 16:05:28
合計ジャッジ時間 4,537 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2**63-1
mod = 998244353
n, m, k = mi()
ans = '2'
#0101...型

s1 = deque(['0'])
cnt0 = 1
cnt1 = 0
for i in range(k):
    if  i % 2 == 0:
        cnt1 += 1
        s1.append('1')
    else:
        cnt0 += 1
        s1.append('0')
if cnt0 <= n and cnt1 <= m:
    while cnt0 < n:
        if s1 and s1[0] == '1':
            t = s1.popleft()
            s1.appendleft('0')
            s1.appendleft(t)
        else:
            s1.appendleft('0')
        cnt0 += 1
    while cnt1 < m:
        if s1 and s1[-1] == '0':
            t = s1.pop()
            s1.append('1')
            s1.append(t)
        else:
            s1.append('1')
        cnt1 += 1
    ans = min(ans, ''.join(s1))
#1010...型

s1 = deque(['1'])
cnt0 = 0
cnt1 = 1
for i in range(k):
    if  i % 2:
        cnt1 += 1
        s1.append('1')
    else:
        cnt0 += 1
        s1.append('0')
if cnt0 <= n and cnt1 <= m:
    while cnt0 < n:
        if s1 and s1[0] == '1':
            t = s1.popleft()
            s1.appendleft('0')
            s1.appendleft(t)
        else:
            s1.appendleft('0')
        cnt0 += 1
    while cnt1 < m:
        if s1 and s1[-1] == '0':
            t = s1.pop()
            s1.append('1')
            s1.append(t)
        else:
            s1.append('1')
        cnt1 += 1
    ans = min(ans, ''.join(s1))

if ans == '2':
    print(-1)
else:
    print(ans)



0