結果

問題 No.2608 Divide into two
ユーザー ryomacryomac
提出日時 2024-01-19 21:36:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 972 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,640 KB
最終ジャッジ日時 2024-01-19 21:36:33
合計ジャッジ時間 1,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

T = int(input())


def calc(N):
    S = N * (N + 1) / 2
    return S


def greedy(N, S):
    num = [i for i in range(1, N + 1)]
    ans = []
    s = []
    for n in num:
        s.append(n)
        if sum(s) == S:
            for i in range(1, N + 1):
                if i in s:
                    ans.append(1)
                else:
                    ans.append(0)
            return ans
        if sum(s) > S:
            while s:
                s = s[1:]
                if sum(s) == S:
                    for i in range(1, N + 1):
                        if i in s:
                            ans.append(1)
                        else:
                            ans.append(0)
                    return ans
            return -1


for _ in range(T):
    N = int(input())
    S = calc(N)
    if S % 2 == 1:
        print(-1)
        continue
    S //= 2
    ans = greedy(N, S)
    if ans == -1:
        print(-1)
    else:
        print("".join(map(str, ans)))
0