結果

問題 No.2247 01 ZigZag
ユーザー first_vil
提出日時 2023-03-17 22:03:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 82,488 KB
実行使用メモリ 89,768 KB
最終ジャッジ日時 2024-09-18 11:03:24
合計ジャッジ時間 8,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,k=map(int,input().split())
d=min(n,m)*2
if n!=m:
    d-=1
if d<k:
    print(-1)
    exit()

def f(n,m,k):
    if n==0:
        return ""
    s="0"
    n-=1
    for i in range(k):
        if ~i&1:
            if m==0:
                return ""
            else:
                s+="1"
        else:
            if n==0:
                return ""
            else:
                s+="0"
    return s
    
s=f(n,m,k)
if not s:
    s=f(m,n,k)
    s=s.replace("1","x").replace("0","1").replace("x","0")
n-=s.count("0")
m-=s.count("1")
if n:
    for i in range(len(s)):
        if s[i]=="0":
            s=s[:i]+"0"*(n+1)+s[i+1:]
            break
if m:
    for i in range(len(s))[::-1]:
        if s[i]=="1":
            s=s[:i]+"1"*(m+1)+s[i+1:]
            break
print(s)
0