結果

問題 No.2608 Divide into two
ユーザー nikoro256nikoro256
提出日時 2024-01-19 21:50:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 637 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,660 KB
最終ジャッジ日時 2024-01-19 21:50:09
合計ジャッジ時間 1,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
70,044 KB
testcase_01 AC 63 ms
72,532 KB
testcase_02 AC 64 ms
72,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

dp=[[False]*10001 for _ in range(101)]
dp[0][0]=True
for i in range(100):
    for j in range(10001):
        if j+i+1<=10001 and dp[i][j]:
            dp[i+1][j+i+1]=True
            dp[i+1][j]=True
T=int(input())
for _ in range(T):
    N=int(input())
    su=(N+1)*N//2
    if su%2==1:
        print(-1)
        continue
    if dp[N][su//2]:
        pos=su//2
        ans=[]
        for i in range(N-1,-1,-1):
            if dp[i][pos]:
                ans.append(0)
            elif dp[i][pos-i-1]:
                ans.append(1)
                pos=pos-i-1
        print(''.join([str(a) for a in ans[::-1]]))
    else:
        print(-1)
0