結果

問題 No.1530 Permutation and Popcount
ユーザー convexineq
提出日時 2021-06-08 18:52:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 436 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-11-26 22:32:53
合計ジャッジ時間 7,885 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 20 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
L = [sum(bin(i*j).count("1")%2 for j in range(1,n+1)) for i in range(1,n+1)]
m += len(L)
v = 1
dp = [1]
for i in L:
    v |= v<<i
    dp.append(v)
if m%2 or dp[-1]>>(m//2)&1==0:
    print(-1)
    exit()
r = m//2
P = []
Q = []
for i,v in enumerate(L[::-1]):
    if r < v or dp[n-i-1]>>(r-v)&1==0:
        Q.append(n-i)
    else:
        P.append(n-i)
        r -= v
print(len(P),len(Q))
print(*P)
print(*Q)
0