結果

問題 No.2608 Divide into two
ユーザー 三浦理稀三浦理稀
提出日時 2024-01-19 22:10:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 463 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-01-19 22:10:35
合計ジャッジ時間 1,291 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
14,080 KB
testcase_01 AC 157 ms
14,080 KB
testcase_02 AC 160 ms
14,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())

dp = [[0]*5001 for _ in range(101)]
dp[0][0] = 1
for i in range(100):
	for j in range(5001):
		if dp[i][j] == 0:
			continue
		if j + (i+1) <= 5000:
			dp[i+1][j+i+1] = 1
		dp[i+1][j] = 1

for _ in range(t):
	n = int(input())
	sm = n*(n+1)//2
	if sm%2 == 1:
		print(-1)
	elif dp[n][sm//2//2]:
		sm //= 2
		ans = ['0']*n
		while sm != 0:
		  if dp[n-1][sm-n]:
		    sm -= n
		    ans[n-1] = '1'
		  n -= 1
		print(''.join(ans))
	else:
		print(-1)
0