思路:我们知道要构成长为x的"0101..."串,首先得计算对应的"0"和"1"够不够,那就可以分别用a, b减去x // 2得到剩余的"0"和"1",记作c, d。接下来先判断c, d是否有负数,如果有的话就无法构成;然后判断c, d是否有奇数,如果有奇数,那么会剩下某个字符无法消去,也就无法构成长为x的01串;否则就可以构成"010100...11..."这样的串,最终消去之后满足长为x的01串
tips:Python3对于字符串的处理要快于PyPy3,因此本题用Python3会跑得更快
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def GMI():
return map(lambda x: int(x) - 1, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
a, b, x = LII()
c, d = a - x // 2, b - x // 2
if c < 0 or d < 0:
print(-1)
elif c & 1 or d & 1:
print(-1)
else:
print('01' * (x // 2) + '0' * c + '1' * d)
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号