結果

問題 No.1530 Permutation and Popcount
ユーザー convexineq
提出日時 2021-06-08 19:00:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,588 KB
実行使用メモリ 76,068 KB
最終ジャッジ日時 2024-11-24 20:40:35
合計ジャッジ時間 4,652 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

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