結果
| 問題 |
No.2247 01 ZigZag
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-03-17 22:15:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| コード長 | 1,077 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 23,356 KB |
| 最終ジャッジ日時 | 2024-09-18 16:11:10 |
| 合計ジャッジ時間 | 4,458 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 |
ソースコード
import sys
input = sys.stdin.readline
N,M,K=map(int,input().split())
z=K//2+1
o=(K+1)//2
if N>=z and M>=o:
ANS=[0]
for i in range(K):
ANS.append(ANS[-1]^1)
rest_0=N-ANS.count(0)
rest_1=M-ANS.count(1)
for i in range(len(ANS)):
if ANS[i]==0:
ANS=ANS[:i]+[0]*rest_0+ANS[i:]
break
for i in range(len(ANS)-1,-1,-1):
if ANS[i]==1:
ANS=ANS[:i]+[1]*rest_1+ANS[i:]
break
if ANS.count(0)==N and ANS.count(1)==M:
print("".join(map(str,ANS)))
exit()
o=K//2+1
z=(K+1)//2
if N>=z and M>=o:
ANS=[1]
for i in range(K):
ANS.append(ANS[-1]^1)
rest_0=N-ANS.count(0)
rest_1=M-ANS.count(1)
for i in range(len(ANS)):
if ANS[i]==0:
ANS=ANS[:i]+[0]*rest_0+ANS[i:]
break
for i in range(len(ANS)-1,-1,-1):
if ANS[i]==1:
ANS=ANS[:i]+[1]*rest_1+ANS[i:]
break
if ANS.count(0)==N and ANS.count(1)==M:
print("".join(map(str,ANS)))
exit()
print(-1)
titia