結果
| 問題 |
No.2608 Divide into two
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-19 21:40:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 1,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 81,988 KB |
| 実行使用メモリ | 73,932 KB |
| 最終ジャッジ日時 | 2024-09-28 04:11:23 |
| 合計ジャッジ時間 | 1,004 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 |
ソースコード
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
dp = [[0]*10000 for i in range(110)]
dp[0][0] = 1
for i in range(1,110):
for j in range(10000):
dp[i][j] |= dp[i-1][j]
dp[i][j] |= dp[i-1][j-i]
t = int(input())
for i in range(t):
n = int(input())
now = n*(n+1)//4
if n*(n+1)%4 != 0:
print(-1)
elif not dp[n][now]:
print(-1)
else:
ans = []
id = n
while id:
if dp[id-1][now-id]:
ans.append("1")
now -= id
else:
ans.append("0")
id -= 1
print("".join(ans[::-1]))