結果

問題 No.1560 majority x majority
ユーザー chocoruskchocorusk
提出日時 2021-06-25 21:58:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 3,389 ms
コンパイル使用メモリ 187,952 KB
実行使用メモリ 6,504 KB
最終ジャッジ日時 2023-09-07 14:29:45
合計ジャッジ時間 9,067 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 447 ms
6,184 KB
testcase_01 AC 431 ms
6,288 KB
testcase_02 AC 4 ms
6,000 KB
testcase_03 AC 538 ms
6,504 KB
testcase_04 AC 367 ms
6,232 KB
testcase_05 AC 499 ms
6,192 KB
testcase_06 AC 118 ms
6,196 KB
testcase_07 AC 19 ms
6,296 KB
testcase_08 AC 394 ms
6,144 KB
testcase_09 AC 212 ms
6,136 KB
testcase_10 AC 3 ms
6,192 KB
testcase_11 AC 24 ms
6,308 KB
testcase_12 AC 6 ms
6,208 KB
testcase_13 AC 32 ms
6,088 KB
testcase_14 AC 7 ms
6,136 KB
testcase_15 AC 161 ms
5,972 KB
testcase_16 AC 3 ms
6,180 KB
testcase_17 AC 419 ms
6,340 KB
testcase_18 AC 75 ms
6,124 KB
testcase_19 AC 4 ms
6,336 KB
testcase_20 AC 4 ms
6,192 KB
testcase_21 AC 5 ms
6,140 KB
testcase_22 AC 169 ms
6,256 KB
testcase_23 AC 4 ms
6,160 KB
testcase_24 AC 3 ms
5,996 KB
testcase_25 AC 145 ms
6,164 KB
testcase_26 AC 2 ms
6,012 KB
testcase_27 AC 3 ms
5,936 KB
testcase_28 AC 2 ms
5,984 KB
testcase_29 AC 3 ms
5,968 KB
testcase_30 AC 3 ms
5,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
    cin>>n>>m;
    int s[5050][13];
    for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin>>s[i][j];
    bitset<5001> b[1<<12];
    for(int i=0; i<(1<<m); i++){
        for(int j=0; j<n; j++){
            b[i][j]=1;
        }
        for(int j=0; j<n; j++){
            for(int k=0; k<m; k++){
                if(i&(1<<k)){
                    if(!s[j][k]) b[i][j]=0;
                }
            }
        }
    }
    ll dp[1<<12]={};
    dp[0]=1;
    for(int i=0; i<(1<<m); i++){
        for(int j=0; j<m; j++){
            if(i&(1<<j)) continue;
            int c=0, c1=0;
            for(int k=0; k<n; k++){
                if(!b[i][k]) continue;
                c++;
                if(s[k][j]) c1++;
            }
            if(c<=c1*2) dp[i^(1<<j)]+=dp[i];
        }
    }
    cout<<dp[(1<<m)-1]<<endl;
    return 0;
}


0