結果

問題 No.2608 Divide into two
ユーザー flygonflygon
提出日時 2024-01-19 21:40:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 1,000 ms
コード長 815 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 73,796 KB
最終ジャッジ日時 2024-01-19 21:40:01
合計ジャッジ時間 1,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
72,260 KB
testcase_01 AC 72 ms
72,900 KB
testcase_02 AC 74 ms
73,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]))
        
0