結果

問題 No.1560 majority x majority
ユーザー rtyurtyu
提出日時 2021-07-13 11:44:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 69,168 KB
実行使用メモリ 23,956 KB
最終ジャッジ日時 2023-09-15 08:38:45
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,888 KB
testcase_01 AC 26 ms
23,936 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 24 ms
23,888 KB
testcase_04 AC 23 ms
23,896 KB
testcase_05 AC 23 ms
23,888 KB
testcase_06 AC 9 ms
23,720 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 13 ms
13,672 KB
testcase_09 AC 10 ms
23,956 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
4,668 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
7,476 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 9 ms
23,768 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 14 ms
13,668 KB
testcase_18 AC 6 ms
7,480 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 9 ms
9,532 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 8 ms
9,536 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int d[5009], c[5009];
bool r[5009][5009];

int main()
{ 
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int a; cin >> a;
			r[(1 << j)][i] = a;
		}
		r[0][i] = 1;
	}
	d[0] = 1; c[0] = n;
	for (int i = 1; i < (1 << m); i++) {
		int p0 = i & (-i), p1 = i - p0;
		for (int j = 0; j < n; j++) {
			r[i][j] = r[p0][j] & r[p1][j];
			c[i] += r[i][j];
		}
		for (int j = 0; j < m; j++)
			if ((i & (1 << j)) && c[i] >= (c[i - (1 << j)] + 1) / 2)
				d[i] += d[i - (1 << j)];
	}
	cout << d[(1 << m) - 1] << '\n';
	return 0;
}
0