結果

問題 No.1530 Permutation and Popcount
ユーザー kotatsugamekotatsugame
提出日時 2021-06-05 04:34:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 73,744 KB
実行使用メモリ 6,964 KB
最終ジャッジ日時 2023-08-16 08:42:25
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 5 ms
6,840 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 5 ms
6,204 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
6,136 KB
testcase_23 AC 5 ms
6,028 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 3 ms
4,496 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 6 ms
6,820 KB
testcase_32 AC 6 ms
6,964 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 6 ms
6,708 KB
testcase_36 AC 6 ms
6,652 KB
testcase_37 AC 6 ms
6,720 KB
testcase_38 AC 6 ms
6,804 KB
testcase_39 AC 6 ms
6,688 KB
testcase_40 AC 6 ms
6,808 KB
testcase_41 AC 6 ms
6,732 KB
testcase_42 AC 6 ms
6,960 KB
testcase_43 AC 5 ms
6,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<bitset>
#include<vector>
using namespace std;
int N,M;
int cnt[301];
bitset<90001>dp[301];
main()
{
	cin>>N>>M;
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=N;j++)cnt[i]+=!__builtin_parity(i*j);
		M-=cnt[i];
		cnt[i]*=2;
	}
	M=-M;
	if(M<0)
	{
		cout<<-1<<endl;
		return 0;
	}
	dp[0][0]=1;
	for(int i=1;i<=N;i++)dp[i]=dp[i-1]|dp[i-1]<<cnt[i];
	if(dp[N][M]==0)cout<<-1<<endl;
	else
	{
		vector<int>X,Y;
		for(int i=N;i>0;i--)
		{
			if(M>=cnt[i]&&dp[i-1][M-cnt[i]])
			{
				Y.push_back(i);
				M-=cnt[i];
			}
			else X.push_back(i);
		}
		cout<<X.size()<<" "<<Y.size()<<endl;
		for(int i=0;i<X.size();i++)cout<<X[i]<<(i+1==X.size()?"\n":" ");
		for(int i=0;i<Y.size();i++)cout<<Y[i]<<(i+1==Y.size()?"\n":" ");
	}
}
0