結果

問題 No.1530 Permutation and Popcount
ユーザー uzzyuzzy
提出日時 2021-06-05 01:18:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,930 bytes
コンパイル時間 2,685 ms
コンパイル使用メモリ 186,900 KB
実行使用メモリ 60,764 KB
最終ジャッジ日時 2024-04-30 17:55:53
合計ジャッジ時間 6,679 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 7 ms
9,708 KB
testcase_11 AC 38 ms
40,320 KB
testcase_12 AC 55 ms
56,704 KB
testcase_13 AC 10 ms
11,764 KB
testcase_14 AC 40 ms
42,356 KB
testcase_15 AC 23 ms
23,932 KB
testcase_16 AC 9 ms
11,624 KB
testcase_17 AC 47 ms
48,620 KB
testcase_18 AC 35 ms
36,364 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 5 ms
6,944 KB
testcase_21 AC 44 ms
44,440 KB
testcase_22 AC 47 ms
48,628 KB
testcase_23 AC 43 ms
44,548 KB
testcase_24 AC 8 ms
11,616 KB
testcase_25 AC 40 ms
40,464 KB
testcase_26 AC 17 ms
17,788 KB
testcase_27 AC 55 ms
56,712 KB
testcase_28 AC 48 ms
50,668 KB
testcase_29 AC 20 ms
22,000 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 57 ms
60,764 KB
testcase_32 WA -
testcase_33 AC 57 ms
58,716 KB
testcase_34 AC 57 ms
58,900 KB
testcase_35 WA -
testcase_36 AC 57 ms
58,760 KB
testcase_37 AC 58 ms
58,848 KB
testcase_38 AC 61 ms
58,752 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 58 ms
58,748 KB
testcase_42 WA -
testcase_43 AC 49 ms
50,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



char dp[310][190100];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, M;
	cin >> N >> M;
	int T[301][301];
	int kazu[301] = {};
	int kei = 0;
	rep1(i, N) rep1(j, N) {
		int tmp = i * j;
		int cnt = 0;
		rep(k, 30) cnt += (tmp >> k & 1);
		T[i][j] = (cnt % 2 == 0);
		kazu[i] += T[i][j];
		kei += T[i][j];
		kazu[i] += T[i][j];
	}

	dp[0][0] = 1;
	rep(i, N) rep(j, 180001) if (dp[i][j] != 0) {
		dp[i + 1][j + kazu[i + 1]] = -(i + 1);
		dp[i + 1][j] = 1;
	}

	int erabu[310] = {}, k = 0;
	if (kei - M >= 0) {
		if (dp[N][kei - M]) {
			int tmp = kei - M;
			for (int i = N; i > 0; i--) {
				if (dp[i][tmp] < 0) {
					erabu[i] = 1;
					k++;
					tmp -= kazu[-dp[i][tmp]];
				}
			}
			cosp(N - k);
			co(k);
			rep1(i, N) if (!erabu[i]) {
				k++;
				if (k < N) cout << i << " ";
				else cout << i << "\n";
			}
			rep1(i, N) if (erabu[i]) {
				cout << i << " ";
			}
			return 0;
		}
	}
	if (kei + M <= 180000) {
		if (dp[N][kei + M]) {
			int tmp = kei + M;
			for (int i = N; i > 0; i--) {
				if (dp[i][tmp] < 0) {
					erabu[i] = 1;
					k++;
					tmp -= kazu[-dp[i][tmp]];
				}
			}
			cosp(k);
			co(N - k);
			rep1(i, N) if (erabu[i]) {
				k--;
				if (k) cout << i << " ";
				else cout << i << "\n";
			}
			rep1(i, N) if (!erabu[i]) {
				cout << i << " ";
			}
			return 0;
		}
	}
	co(-1);
	return 0;

	Would you please return 0;
}
0