結果
| 問題 | No.2608 Divide into two |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-19 21:40:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 715 bytes |
| 記録 | |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 64,408 KB |
| 最終ジャッジ日時 | 2024-09-28 04:12:38 |
| 合計ジャッジ時間 | 1,403 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 2 |
ソースコード
T = int(input())
for _ in range(T):
N = int(input())
if N * (N + 1) // 2 & 1:
print(-1)
continue
ans = [0] * N
if N % 2 == 0:
for i in range(N // 2):
ans[i] = i & 1
for i in range(N // 2, N):
ans[i] = (i + 1) & 1
else:
S = set(range(1, N + 1))
A = list(range(1, N + 1))
ss = set()
n = 0
nn = N * (N + 1) // 4
while n < nn:
if nn - n in S:
ss.add(nn - n)
S.discard(nn - n)
break
s = A.pop()
n += s
S.discard(s)
ss.add(s)
for n in ss:
ans[n - 1] = 1
print(*ans)