結果

問題 No.1560 majority x majority
ユーザー 李凯麟李凯麟
提出日時 2021-07-15 23:43:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,571 bytes
コンパイル時間 1,437 ms
コンパイル使用メモリ 165,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 08:53:17
合計ジャッジ時間 3,200 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
4,376 KB
testcase_01 AC 94 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 92 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 36 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 27 ms
4,376 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 12 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 11 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e6+7;
#define FOR(i,n) for(int i=0;i<n;++i)
int dp[1<<13];//表示S能搞完的方案数
//dp[]
int C[maxn];
int N,M;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		x=0;
		FOR(j,M) {
			cin>>y;
			x=x*2+y;
		}
		C[x]++;
	}
	
	dp[0]=1;
	int mask,mask2;
	FOR(mask,1<<M) if(dp[mask]) {
		FOR(j,M) if((mask&(1<<j))==0) {
			int win=0,lose=0;
			FOR(mask2,1<<M) if((mask&mask2)==mask) {
				if(mask2&(1<<j)) win+=C[mask2];
				else win-=C[mask2];
			}
			if(win>=0) dp[mask|(1<<j)]+=dp[mask];
		}
	}
	cout<<dp[(1<<M)-1]<<endl;
}
signed main() {
	solve();
}
0